fix(config): versionFromImage must not return digest hex; sync contract fixture - #22
Merged
Merged
Conversation
…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.
There was a problem hiding this comment.
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 inversionFromImage()so digest-only images yieldundefinedandapp:v1@sha256:...yieldsv1. - Add regression tests covering digest-pinned image references (including registry-port cases).
- Update the schemaVersion 1
nais.jscontract 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consumer-side follow-ups from the adversarial review of nais/naiserator#687 (full findings posted there):
versionFromImagedigest bug — the same defect found in naiserator's generator exists here: for a digest-pinned image (app@sha256:…) the digest's colon wonlastIndexOf(':')and 64 hex chars leaked intoapp.version. Now the@digestsuffix 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 andNAIS_APP_IMAGEpaths agree on every image form.nais.jsasexport default <marshalled JSON>;(one escaped serialization backing both formats). The verbatimNAIS_JS_V1fixture is updated to the new golden output; the pre-#687V0shape stays pinned for tolerance.208 tests passing.
Note: mergeable independently of nais/naiserator#687 —
fromNaisConfigprobes fields, so it accepts old, intermediate, and new shapes alike.