Repository navigation
[Test Quality] Pin compose sanitizer structure preservation - #11459
Merged
lpcox merged 1 commit intoNov 11, 2026
Merged
Conversation
Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the added regression tests cover structure preservation and safe handling of malformed or non-mapping Compose YAML values.
No open issues 🎉
What changed in this PR
This test-only PR strengthens sanitizeDockerComposeYaml coverage by verifying that environment redaction preserves unrelated Compose structure and safely handles malformed service entries and non-mapping YAML values.
Changes:
- Adds mixed-service coverage for null, scalar, list, and environment-bearing services.
- Verifies non-mapping YAML documents are returned unchanged.
- Verifies list-valued
servicesentries round-trip safely.
| File | Description |
|---|---|
| src/compose-sanitizer.test.ts | Adds parser-backed regression tests covering Compose structure preservation, malformed service entries, and non-mapping YAML inputs. |
Review effort: Lite (auto)
Contributor
Author
|
✅ Copilot review passed with no inline comments. @github-actions[bot] Add the |
lpcox
deleted the
test-quality/compose-sanitizer-shape-34cc2c6010205166
branch
November 11, 2026 18:11
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.
Contract
sanitizeDockerComposeYaml(src/compose-sanitizer.ts) redacts service environment values in compose snapshots and must leave everything else intact. It must not addenvironmentto services that lack one. It must tolerate malformedservicesentries (null, scalar, list) and a non-mappingserviceskey. Non-mapping YAML is returned unchanged.Weakness
The existing tests only covered environment redaction. If the per-service shape guard (
!service || typeof service !== 'object' || Array.isArray(service)) were removed,redactComposeServiceEnvironmentwould crash on a null service. That change was not detected.Change
Test-only, in
src/compose-sanitizer.test.ts. Three tests use the real YAML parser and serializer, with no mocks:serviceskey round-trips.I deliberately did not pin the current behavior of empty input, which throws.
Evidence
Mutation: remove the service-shape guard in
src/compose-sanitizer.ts.Command:
./node_modules/.bin/jest --runInBand --no-coverage --runTestsByPath src/compose-sanitizer.test.tsESLint is clean on the changed file.
CI
npm test(root Jest) in.github/workflows/build.ymldiscovers the file. This is a component-level test only, not container or network enforcement.