Skip to content

[deckhouse-cli] Fix misleading error message for registry path#405

Open
Glitchy-Sheep wants to merge 1 commit into
mainfrom
fix/update-out-error-messages
Open

[deckhouse-cli] Fix misleading error message for registry path#405
Glitchy-Sheep wants to merge 1 commit into
mainfrom
fix/update-out-error-messages

Conversation

@Glitchy-Sheep

Copy link
Copy Markdown
Contributor

Summary

Pushing to a registry root (e.g. localhost:5000) failed with a raw go-containerregistry error about invalid characters. Users read it as "the port is not allowed". Now the CLI says what is actually missing: the repository path.

Problem

  • d8 mirror push distr/ localhost:5000 --insecure fails with:
    Validate registry address: repository can only contain the characters 'abcdefghijklmnopqrstuvwxyz0123456789_-./': localhost:5000
  • The real cause: the address must include a repository path (localhost:5000/deckhouse). Pushing to a registry root is not supported.
  • The message points at characters, and the only suspicious character in the input is the : before the port.
  • Root cause: without a / in the address, name.NewRepository validates the whole host:port string as a repository name, where : is illegal. The friendlier host and path checks below never run.

Fix

  • Check for a missing repository path before calling name.NewRepository.
  • Applied to both inputs: mirror push <registry> and mirror pull --source.
  • The new error names the argument, shows the expected format, and builds an example from the user's own input.
  • Remaining parse errors now name the argument instead of the generic Validate registry address: wrapper.
  • Docs: format example added to the mirror README and the --source flag help.
  • Error-path only: every address that was valid before stays valid (pinned by tests).

Before / After

Before:

2026-07-14 AT 13 34@2x

After:

2026-07-14 AT 13 34@2x

Tests

  • TestParseAndValidateRegistryURLArg (push): new cases for localhost:5000, http:// scheme stripping, trailing slash, and the full new message text.
  • Same test: backward-compat pins for 192.168.1.1:5000/repo, myregistry/repo, localhost:5000//repo - they stay accepted.
  • TestValidationValidateSourceRegistry (pull): new cases for localhost:5000 and trailing slash; the existing "no path" case now asserts the new message.

- `d8 mirror push` and `pull --source` now explain what is missing: expected format `registry-host[:port]/path` plus an example built from the user's own input.
- Without a path, `name.NewRepository` validates the whole `host:port` as a repository name and blames the `:`, so users read the error as "ports are not allowed".
- Remaining parse errors name the argument (`<registry>`, `--source`) so it is clear which input is bad.
- Tests pin the new messages and keep currently-valid addresses accepted (`myregistry/repo`, `localhost:5000//repo`, IP with port).

Signed-off-by: Roman Berezkin <roman.berezkin@flant.com>
@Glitchy-Sheep Glitchy-Sheep self-assigned this Jul 14, 2026
@Glitchy-Sheep Glitchy-Sheep added the enhancement New feature or request label Jul 14, 2026
@Glitchy-Sheep Glitchy-Sheep marked this pull request as ready for review July 14, 2026 10:35
@Glitchy-Sheep Glitchy-Sheep requested a review from ldmonster as a code owner July 14, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant