Skip to content

fix(config): versionFromImage must not return digest hex; sync contract fixture - #22

Merged
Starefossen merged 1 commit into
mainfrom
fix/version-from-image-digest
Jul 13, 2026
Merged

fix(config): versionFromImage must not return digest hex; sync contract fixture#22
Starefossen merged 1 commit into
mainfrom
fix/version-from-image-digest

Conversation

@Starefossen

Copy link
Copy Markdown
Member

Consumer-side follow-ups from the adversarial review of nais/naiserator#687 (full findings posted there):

  1. versionFromImage digest bug — the same defect found in naiserator's generator exists here: for a digest-pinned image (app@sha256:…) the digest's colon won lastIndexOf(':') and 64 hex chars leaked into app.version. Now the @digest suffix is stripped first: digest-only → undefined, app:v1@sha256:…v1. naiserator's generator (as of nais/naiserator@a7762b3) mirrors this logic exactly, so the generatedConfig and NAIS_APP_IMAGE paths agree on every image form.
  2. Contract fixture sync — after the injection fix, naiserator emits nais.js as export default <marshalled JSON>; (one escaped serialization backing both formats). The verbatim NAIS_JS_V1 fixture is updated to the new golden output; the pre-#687 V0 shape stays pinned for tolerance.

208 tests passing.

Note: mergeable independently of nais/naiserator#687fromNaisConfig probes fields, so it accepts old, intermediate, and new shapes alike.

…ct fixture

Both from the nais/naiserator#687 adversarial review:

- versionFromImage: strip the @digest suffix before tag extraction so a
  digest-pinned image (app@sha256:...) yields no version instead of 64
  hex chars, and app:v1@sha256:... yields v1. naiserator's generator now
  mirrors this exact logic so both platform resolution paths agree.
- naisConfigContract fixture: the schemaVersion 1 nais.js is now
  'export default <marshalled JSON>;' (one escaped serialization backs
  both formats after the injection fix in naiserator) - fixture updated
  to the new verbatim generator output.
Copilot AI review requested due to automatic review settings July 12, 2026 20:51

Copilot AI 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.

Pull request overview

This PR aligns @nais/apm’s config resolution with naiserator’s post-#687 contract by fixing versionFromImage() so digest-pinned images don’t leak digest hex into app.version, and by syncing the schemaVersion 1 nais.js contract fixture to the new golden output.

Changes:

  • Strip @sha256:... (digest suffix) before tag parsing in versionFromImage() so digest-only images yield undefined and app:v1@sha256:... yields v1.
  • Add regression tests covering digest-pinned image references (including registry-port cases).
  • Update the schemaVersion 1 nais.js contract fixture to the new JSON-marshalled output format.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/config.ts Fixes versionFromImage() to ignore digest suffixes before tag extraction.
src/config.test.ts Adds regression coverage to prevent digest hex from becoming app.version.
src/naisConfigContract.test.ts Syncs the NAIS_JS_V1 fixture to the updated naiserator nais.js output format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Starefossen
Starefossen added this pull request to the merge queue Jul 13, 2026
Merged via the queue into main with commit 54b66e1 Jul 13, 2026
7 checks passed
@Starefossen
Starefossen deleted the fix/version-from-image-digest branch July 13, 2026 08:30
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.

2 participants