Skip to content

Validate image tag format in config and improve error message#256

Merged
anisaoshafi merged 6 commits into
mainfrom
devx-859-improve-error-message-for-invalid-image-tags
May 21, 2026
Merged

Validate image tag format in config and improve error message#256
anisaoshafi merged 6 commits into
mainfrom
devx-859-improve-error-message-for-invalid-image-tags

Conversation

@anisaoshafi
Copy link
Copy Markdown
Collaborator

@anisaoshafi anisaoshafi commented May 20, 2026

Motivation

We don't validate the version tag in config.toml so users discover later in the flow some tags are not possible.
Also the error message was not pointing to the real issue.

Changes

  • Reject tags that don't conform to Docker's tag format rules at config load (invalid chars, leading ./-, >128 chars). Fails fast before any network or Docker operation.
  • Normalize tags with zero-padded calendar months (2026.04 → suggest 2026.4) before license validation
  • The suggested valid tag in error messages is computed from the previous calendar month, so it's a reasonable recent version.
  • License API error improvement: when the license API returns 400 with a licensing.license.format body, the error now says "unsupported image tag" instead of the generic token/subscription message, which is more actionable for the user.

a) Before // inaccurate message
image

b) Now: tag="3.99.99" // valid tag regex, but does't exist: license server complains
image

c) Now: tag="2026.04" // valid tag, previously failed with error a)
image

@anisaoshafi anisaoshafi force-pushed the devx-859-improve-error-message-for-invalid-image-tags branch 4 times, most recently from 837fed2 to d2c64f5 Compare May 20, 2026 11:48
@anisaoshafi anisaoshafi marked this pull request as ready for review May 20, 2026 12:05
@anisaoshafi anisaoshafi requested a review from gtsiolis May 20, 2026 12:06
@gtsiolis
Copy link
Copy Markdown
Member

Cross-posting relevant decision to redirect this to support zero padding.

@anisaoshafi anisaoshafi marked this pull request as draft May 20, 2026 13:52
@anisaoshafi
Copy link
Copy Markdown
Collaborator Author

anisaoshafi commented May 20, 2026

Cross-posting relevant decision to redirect this to support zero padding.

Adjusted according to discussion [1] 🙏🏼

@anisaoshafi anisaoshafi marked this pull request as ready for review May 20, 2026 14:01
Copy link
Copy Markdown
Member

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UX LGTM, works as expected. 💯

Copy link
Copy Markdown
Collaborator

@carole-lavillonniere carole-lavillonniere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 good one! Added just one small concern, good to go after it's addressed

Comment thread internal/container/start.go Outdated
opts.Logger.Error("license server response (HTTP %d): %s", licErr.Status, licErr.Detail)
}
if licErr.IsUnsupportedTag {
licErr.Message = config.UnsupportedTagMessage()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: it's unusual to mutate an error message. Can we wrap the error instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went with this approach to avoid a future circular dependancy: 0830aa9. will address now. Thanks for checking 🙏

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed here: 463b358

@anisaoshafi anisaoshafi force-pushed the devx-859-improve-error-message-for-invalid-image-tags branch from 6415826 to 463b358 Compare May 21, 2026 08:59
@anisaoshafi anisaoshafi merged commit c6fc260 into main May 21, 2026
12 checks passed
@anisaoshafi anisaoshafi deleted the devx-859-improve-error-message-for-invalid-image-tags branch May 21, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants