Skip to content

Keep mirror_images.yaml's header when regenerating - #7663

Draft
christophe-papazian wants to merge 3 commits into
mainfrom
christophe-papazian/mirror-images-header
Draft

Keep mirror_images.yaml's header when regenerating#7663
christophe-papazian wants to merge 3 commits into
mainfrom
christophe-papazian/mirror-images-header

Conversation

@christophe-papazian

Copy link
Copy Markdown
Contributor

APPSEC-69943

mirror_images.py add rewrites mirror_images.yaml through 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 add and re-apply it after. It preserves what is in the file rather than rewriting from this script's MIRROR_YAML_HEADER constant, 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

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>
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

tests/test_the_test/test_update_mirror_images.py                        @DataDog/system-tests-core
utils/scripts/update_mirror_images.py                                   @DataDog/system-tests-core

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Sep 7, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 1 Pipeline job failed

DataDog/system-tests | Ubuntu_24_amd64.MUL: [test-app-ruby-multicontainer]

View more details · View in GitLab

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: bb165cd | Docs | View more details | Give us feedback!

christophe-papazian and others added 2 commits September 7, 2026 11:42
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>
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.

1 participant