Keep mirror_images.yaml's header when regenerating - #7663
Draft
christophe-papazian wants to merge 3 commits into
Draft
Keep mirror_images.yaml's header when regenerating#7663christophe-papazian wants to merge 3 commits into
christophe-papazian wants to merge 3 commits into
Conversation
APPSEC-69943 `mirror_images.py add` rewrites the file through a YAML parser, which discards comments, but only when it actually adds an image. Regenerating after a new image therefore deleted the file's own documentation, including the command for regenerating it. CI never caught it because nothing is added in steady state, so the file is not rewritten and the header survives. Capture whatever preamble is committed before the add and re-apply it after, rather than rewriting from the constant in this script, whose wording has drifted from the file. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
|
|
Review findings.
The preamble was checked with startswith("---"), so a header whose marker is
not on the first line left the serializer's own marker in place and produced
two YAML documents, which a single-document loader rejects with ComposerError.
Reproduced, then keyed off a document start anywhere in the preamble instead.
Only reachable if the serializer emits a marker, which it currently does not,
and the committed header starts with one.
The comment above MIRROR_YAML_HEADER claimed `add` preserves existing
comments. It does not, which is the belief this whole bug rested on.
Adds regression tests for the four cases: `add` rewriting the file, an
unchanged file staying byte-identical, first-time creation, and marker
ordering. The ordering test fails against the previous check.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
APPSEC-69943
mirror_images.py addrewritesmirror_images.yamlthrough a YAML parser, which discards comments — but only when it actually adds an image. Regenerating after adding one therefore deleted the file header, including the line documenting how to regenerate it. Steady-state CI never catches this, because nothing is added, so the file is not rewritten.Fix: capture the committed preamble before the
addand re-apply it after. It preserves what is in the file rather than rewriting from this script'sMIRROR_YAML_HEADERconstant, whose wording has drifted from it.Verified by removing an entry and regenerating: the entry comes back, the header survives, and the file is byte-identical to before.
Split out of #7625, where adding the python base image tags hit this.
🤖 Generated with Claude Code