Skip to content

πŸ› fix(tag): stop suggesting prerelease tags that coerce to stable versions (#473) - #482

Merged
scttbnsn merged 1 commit into
mainfrom
fix/473-prerelease-suggested-tag
Jul 6, 2026
Merged

scttbnsn merged 1 commit into
mainfrom
fix/473-prerelease-suggested-tag

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the suggested-tag mislabel from discussion #473.

A Home Assistant latest container with a digest update showed the digest correctly but labeled it with an unrelated dev tag (2026.8.0.dev202607050315). Root cause: suggest() accepted any tag that semver.coerce() could mangle into a version β€” PEP 440-style tags like 2026.8.0.dev202607050315 coerce to a "stable" 2026.8.0, sail past the prerelease check, and win the sort. The old PRERELEASE_LABEL_PATTERN guard missed them because PEP 440 glues the dev keyword straight onto the digits with no separator.

The fix replaces the pattern denylist with a structural guard: if a candidate tag only parses via the lossy coerce() fallback, it's rejected unless the raw tag is a bare numeric version (v?X, v?X.Y, v?X.Y.Z). That keeps legitimate 1- and 2-part stable tags (13.4, v2) suggestible while shutting out every keyword-glued prerelease format, not just a hard-coded list.

UI side: the grouped containers view rendered the suggested tag as a raw span; it now uses SuggestedTagBadge like the other views, so suggested tags get consistent treatment there.

Gate: app + UI suites green at 100% coverage, build/typecheck/biome clean, e2e + playwright via pre-push hook. Verified against the real registry data from the report (Docker Hub + ghcr digest tables are byte-identical β€” the digest shown was always correct; only the label was wrong).

πŸ› Fixed

  • Corrected suggested-tag selection so PEP 440 β€œdev”/nightly-style prereleases (e.g., 2026.8.0.dev...) no longer get mis-ranked ahead of the real stable tag (discussion #473).
  • Rejects tag candidates that only qualify through semver.coerce()’s lossy fallback (requiredCoercionFallback), unless the raw tag matches a bare numeric form (v?X, v?X.Y, or v?X.Y.Z).
  • Adds an invariant documenting why the normalizeNumericMultiSegmentTag branch does not need a mirrored guard in requiredCoercionFallback.
  • Updated grouped container β€œUpdate state” rendering so the raw suggested value is shown only via SuggestedTagBadge, not as unlabeled text.

πŸ”§ Changed

  • Refactored app/tag/suggest stability eligibility: removed the prerelease denylist approach and replaced it with structural checks tied to whether coercion fallback was required, while still requiring parse() to produce no prerelease parts.
  • Updated ui/src/components/containers/ContainersGroupedViews.vue to render suggested tags using SuggestedTagBadge in the β€œUpdate state” cell.

✨ Added

  • Expanded app/tag/suggest.test.ts with regression/edge-case coverage for #473 and additional tag-format handling (rejections for dev/post-release suffixes, CalVer-like formats, coercion-lossy OS-variants; acceptances for bare numeric formats and stable build metadata; and semver tie-breaking behavior).
  • Added app/watchers/providers/docker/image-comparison.test.ts coverage ensuring the digest-watch flow proposes the correct stable tag alongside a PEP 440 nightly/dev tag without disrupting digest comparison logic.
  • Updated ui/tests/components/containers/ContainersGroupedViews.spec.ts to:
    • Assert no suggested-tag-badge renders when fixtures have no suggestedTag.
    • Add a #473 regression validating the badge presence and that the raw suggested tag string is not shown as plain text.

@vercel

vercel Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
drydock-website Ready Ready Preview, Comment Jul 6, 2026 3:15am
drydockdemo-website Ready Ready Preview, Comment Jul 6, 2026 3:15am

@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3cf5c2cf-8fdd-4cce-9aca-e63d8af3c462

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 23f57d1 and c21d7df.

β›” Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
πŸ“’ Files selected for processing (5)
  • app/tag/suggest.test.ts
  • app/tag/suggest.ts
  • app/watchers/providers/docker/image-comparison.test.ts
  • ui/src/components/containers/ContainersGroupedViews.vue
  • ui/tests/components/containers/ContainersGroupedViews.spec.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • ui/src/components/containers/ContainersGroupedViews.vue
  • app/watchers/providers/docker/image-comparison.test.ts
  • app/tag/suggest.ts
  • ui/tests/components/containers/ContainersGroupedViews.spec.ts
  • app/tag/suggest.test.ts

πŸ“ Walkthrough

Walkthrough

app/tag/suggest.ts now filters stable semver candidates with coercion-fallback and bare-numeric checks instead of prerelease-label exclusion. Added tests cover dev/post tags, dotted dev rejection, CalVer rejection, build metadata, numeric formats, and patch ordering. A docker image-comparison test now uses the real suggest() path. In the UI, ContainersGroupedViews.vue renders SuggestedTagBadge for suggested tags, and the component tests now check badge presence and raw tag text exposure.

Changes

Cohort / File Change
Tag suggestion logic β€” app/tag/suggest.ts Replaced prerelease-label exclusion with coercion-fallback/bare-numeric-pattern stable candidate filtering
app/tag/suggest.test.ts Added regression tests for dev/post/CalVer/build-metadata/numeric tag formats
app/watchers/providers/docker/image-comparison.test.ts Added test using real suggest() to verify stable tag suggestion unaffected by digest path
Suggested-tag badge β€” ui/src/components/containers/ContainersGroupedViews.vue Replaced inline suggested-tag span with SuggestedTagBadge component
ui/tests/components/containers/ContainersGroupedViews.spec.ts Updated/added tests for badge presence/absence and tag text exposure

Sequence Diagram(s)

sequenceDiagram
  participant ContainersGroupedViews
  participant SuggestedTagBadge
  ContainersGroupedViews->>SuggestedTagBadge: pass tag=c.suggestedTag, current-tag=c.currentTag
  SuggestedTagBadge-->>ContainersGroupedViews: render "Suggested" badge with tooltip
Loading

Compact metadata
Related issues: #473
Related PRs: None specified
Suggested labels: bug, tests, ui
Suggested reviewers: None specified

πŸš₯ Pre-merge checks | βœ… 2
βœ… Passed checks (2 passed)
Check name Status Explanation
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/473-prerelease-suggested-tag

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
app/tag/suggest.ts (1)

106-128: πŸ“ Maintainability & Code Quality | πŸ”΅ Trivial | ⚑ Quick win

Duplicated coercion-detection logic relies on an undocumented invariant.

requiredCoercionFallback re-implements only the semver.clean + semver.parse portion of parse()'s fallback chain in app/tag/index.ts, but omits the normalizeNumericMultiSegmentTag branch. This is currently safe only because any tag matching that branch always gets a non-empty prerelease array and is already rejected earlier at Line 121-124 β€” but that coupling isn't documented here, and if normalizeNumericMultiSegmentTag's pattern or behavior changes in index.ts later, this file won't automatically stay in sync, risking reintroducing the exact class of bug (#473) this PR fixes.

Consider deriving "did coercion happen" directly from the shared parsing pipeline instead of re-deriving it independently, or at minimum add a comment noting why the multi-segment branch doesn't need to be replicated here.

♻️ Example: expose coercion info from the shared parser instead of duplicating logic
-function requiredCoercionFallback(tag: string): boolean {
-  const cleaned = semver.clean(tag, { loose: true });
-  return semver.parse(cleaned ?? tag) === null;
-}
+// NOTE: parseSemver's underlying parse() also has a `normalizeNumericMultiSegmentTag`
+// branch; any tag hitting it always produces a non-empty `prerelease`, so it is
+// already excluded above at the `prerelease.length > 0` check. If that branch's
+// behavior changes upstream, re-verify this invariant still holds.
+function requiredCoercionFallback(tag: string): boolean {
+  const cleaned = semver.clean(tag, { loose: true });
+  return semver.parse(cleaned ?? tag) === null;
+}
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/tag/suggest.ts` around lines 106 - 128, The coercion check in
requiredCoercionFallback duplicates part of parse()’s fallback logic and depends
on an implicit prerelease invariant from isStableSemverCandidate. Update
requiredCoercionFallback and isStableSemverCandidate to use the shared parsing
pipeline from app/tag/index.ts (or another shared helper) so coercion detection
stays in sync with parseSemver/normalizeNumericMultiSegmentTag. If you keep the
current approach, add a brief comment near requiredCoercionFallback explaining
why the normalizeNumericMultiSegmentTag branch does not need to be mirrored
here.
πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/tag/suggest.ts`:
- Around line 106-128: The coercion check in requiredCoercionFallback duplicates
part of parse()’s fallback logic and depends on an implicit prerelease invariant
from isStableSemverCandidate. Update requiredCoercionFallback and
isStableSemverCandidate to use the shared parsing pipeline from app/tag/index.ts
(or another shared helper) so coercion detection stays in sync with
parseSemver/normalizeNumericMultiSegmentTag. If you keep the current approach,
add a brief comment near requiredCoercionFallback explaining why the
normalizeNumericMultiSegmentTag branch does not need to be mirrored here.

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 89aaa60b-e1f0-4cd5-bb4a-646e646b079f

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between bec684e and d1a7297.

β›” Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
πŸ“’ Files selected for processing (5)
  • app/tag/suggest.test.ts
  • app/tag/suggest.ts
  • app/watchers/providers/docker/image-comparison.test.ts
  • ui/src/components/containers/ContainersGroupedViews.vue
  • ui/tests/components/containers/ContainersGroupedViews.spec.ts

@scttbnsn
scttbnsn force-pushed the fix/473-prerelease-suggested-tag branch from d1a7297 to 23f57d1 Compare July 6, 2026 02:47
@scttbnsn

scttbnsn commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Added the invariant comment on requiredCoercionFallback explaining why the normalizeNumericMultiSegmentTag branch doesn't need mirroring here (any tag it rewrites comes back with a non-empty prerelease array and dies at the prerelease check first).

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Round-trip coercion guard is the right shape β€” keeps bare 2-part stables while killing keyword-glued prereleases.

ALARGECOMPANY
ALARGECOMPANY previously approved these changes Jul 6, 2026

@ALARGECOMPANY ALARGECOMPANY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving β€” verified against the reporter's registry data, digest behavior unchanged.

…sions (#473)

- πŸ› fix(tag): reject suggest() candidates that needed lossy semver coercion unless the raw tag is bare-numeric β€” PEP 440 nightlies (e.g. HA 2026.8.0.devYYYYMMDDHHMM) no longer masquerade as stable pin hints
- πŸ› fix(ui): render the containers-table suggested-tag hint through SuggestedTagBadge (labeled + tooltip) instead of a raw unlabeled string beside the Digest/NEW badges
- βœ… test: #473 regression coverage (HA nightly scheme, PEP 440 post/dev, CalVer and OS-suffix rejection, badge rendering)

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-approving after the rebase onto the merged #481 β€” CHANGELOG resolution only, code unchanged.

@ALARGECOMPANY ALARGECOMPANY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Re-approving post-rebase, gate green.

@scttbnsn
scttbnsn merged commit 322012d into main Jul 6, 2026
24 checks passed
@scttbnsn
scttbnsn deleted the fix/473-prerelease-suggested-tag branch July 6, 2026 03:30

This branch was successfully deployed

2 active deployments
Preview – drydockdemo-website β€” c21d7df9 Deployed Jul 6, 2026 by vercel[bot]
Preview – drydock-website β€” c21d7df9 Deployed Jul 6, 2026 by vercel[bot]
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.

3 participants