Skip to content

[Test Quality] Pin compose sanitizer structure preservation - #11459

Merged
lpcox merged 1 commit into
mainfrom
test-quality/compose-sanitizer-shape-34cc2c6010205166
Nov 11, 2026
Merged

lpcox merged 1 commit into
mainfrom
test-quality/compose-sanitizer-shape-34cc2c6010205166

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Contract

sanitizeDockerComposeYaml (src/compose-sanitizer.ts) redacts service environment values in compose snapshots and must leave everything else intact. It must not add environment to services that lack one. It must tolerate malformed services entries (null, scalar, list) and a non-mapping services key. 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, redactComposeServiceEnvironment would 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:

  • Exact whole-document equality for mixed services (no env, null, scalar, list, with env).
  • Non-mapping documents returned byte-identical.
  • A list-valued services key 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.

  • Old test file: 38/38 pass, so the mutation is missed.
  • New test file: 1 fails ("preserves non-environment content..."), 42 pass.
  • Mutation reverted; clean rerun: 43/43 pass.

Command: ./node_modules/.bin/jest --runInBand --no-coverage --runTestsByPath src/compose-sanitizer.test.ts

ESLint is clean on the changed file.

CI

npm test (root Jest) in .github/workflows/build.yml discovers the file. This is a component-level test only, not container or network enforcement.

Generated by Test Quality Improver · copilot · auto (Claude Sonnet 5.5) · ~26 AIC · ⌖ ~2 AIC · ⊞ 11.6K · ◷

  • expires on Dec 11, 2026, 12:37 PM UTC

@lpcox
lpcox marked this pull request as ready for review November 11, 2026 16:03
Copilot AI adaptive review requested due to automatic review settings November 11, 2026 16:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 services entries 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)

@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Copilot review passed with no inline comments.

@github-actions[bot] Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox
lpcox merged commit afd47b6 into main Nov 11, 2026
46 of 58 checks passed
@lpcox
lpcox deleted the test-quality/compose-sanitizer-shape-34cc2c6010205166 branch November 11, 2026 18:11
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