Skip to content

Comments

Improve error messages for invalid OCI repository names in rad bicep publish#178

Draft
Copilot wants to merge 16 commits intomainfrom
copilot/improve-oci-error-message
Draft

Improve error messages for invalid OCI repository names in rad bicep publish#178
Copilot wants to merge 16 commits intomainfrom
copilot/improve-oci-error-message

Conversation

Copy link

Copilot AI commented Nov 14, 2025

Description

When users provide invalid OCI repository names in rad bicep publish --target, the error from oras-go (invalid reference: invalid repository "...") doesn't explain OCI naming rules or how to fix the issue.

Changes

  • Added enhanceOCIError() function that wraps oras-go validation errors with detailed messages explaining:
    • Which component is invalid (registry, repository, or tag)
    • Specific OCI naming requirements for that component
    • Valid examples
    • Link to OCI specification
  • Updated extractDestination() to use enhanced error handling
  • Added test suite covering uppercase repository names, invalid tags, and missing components

Example

Before:

Error: invalid reference: invalid repository "myregistry/Data/mySqlDatabases"

After:

Invalid OCI repository name in target "localhost:5000/myregistry/Data/mySqlDatabases:latest".

OCI repository names must:
  - Contain only lowercase letters (a-z), digits (0-9), periods (.), underscores (_), and hyphens (-)
  - Start with a lowercase letter or digit
  - Separate path components with forward slashes (/)
  - Not contain consecutive special characters except double underscores (__)

Example: 'br:localhost:5000/myregistry/data/mysqldatabases:latest'

For more information on OCI naming conventions, see:
https://github.com/opencontainers/distribution-spec/blob/main/spec.md

Cause: invalid reference: invalid repository "myregistry/Data/mySqlDatabases"

Type of change

  • This pull request fixes a bug in Radius and has an approved issue (issue link required).

Fixes: #issue_number

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
    • Yes
    • Not applicable
  • A design document PR is created in the design-notes repository, if new APIs are being introduced.
    • Yes
    • Not applicable
  • The design document has been reviewed and approved by Radius maintainers/approvers.
    • Yes
    • Not applicable
  • A PR for the samples repository is created, if existing samples are affected by the changes in this PR.
    • Yes
    • Not applicable
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
    • Yes
    • Not applicable
  • A PR for the recipes repository is created, if existing recipes are affected by the changes in this PR.
    • Yes
    • Not applicable
Original prompt

This section details on the original issue you should resolve

<issue_title>Improve error message for invalid OCI repository name in rad bicep publish --target argument</issue_title>
<issue_description>### Overview of feature request

When running the rad bicep publish command, the --target argument must comply with OCI registry naming rules for specifying the registry, repository, and tag. If the argument fails validation, the error message from the oras.land/oras-go/v2/registry.ParseReference(string) command is returned. The problem is that the message is not descriptive enough to inform the user that the name is invalid. For example, the command below attempts to run rad bicep publish with uppercase characters in the --target argument, which is invalid according to OCI naming rules.

$ rad bicep publish --file kubernetes-mysql.bicep --target "br:localhost:5000/myregistry/Data/mySqlDatabases/kubernetes/kubernetesmysql:latest" --plain-http
Building bicep/kubernetes-mysql.bicep...
Error: invalid reference: invalid repository "myregistry/Data/mySqlDatabases/kubernetes/kubernetesmysql"

The desired behavior is that the error message would explain that OCI naming rules are being enforced, and give the user some idea about how to discover what those rules are, or give the user a summary of the rules.

Acceptance criteria

acceptance-criteria:

  • The error message for invalid --target arguments during rad bicep publish must explicitly state that OCI naming rules are being enforced.
  • The error message must indicate which part of the --target argument is invalid (registry, repository, or tag).
  • The error message must include a brief summary of OCI naming rules or provide a link to documentation for those rules.
  • The error message must guide users to correct their argument, such as suggesting lowercase characters for repository names.
  • The error message must help users understand why their input failed validation and how to resolve the issue.
  • Validation logic should be consistent with the rules implemented in reference.go.

Additional context

The library that Radius uses to parse the name is here: https://github.com/oras-project/oras-go/blob/main/registry/reference.go#L119-L120
Link to the Radius code: https://github.com/radius-project/radius/blob/main/pkg/cli/cmd/bicep/publish/publish.go#L298

Would you like to support us?

  • Yes, I would like to support you

AB#17295</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 14, 2025 04:24
Co-authored-by: brooke-hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Co-authored-by: brooke-hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve error message for invalid OCI repository name Improve error messages for invalid OCI repository names in rad bicep publish Nov 14, 2025
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error message for invalid OCI repository name in rad bicep publish --target argument

2 participants