Skip to content

test(format): redact plumb_version in JSON snapshots - #251

Merged
aram-devdocs merged 1 commit into
mainfrom
fix/redact-plumb-version-snapshot
May 7, 2026
Merged

test(format): redact plumb_version in JSON snapshots#251
aram-devdocs merged 1 commit into
mainfrom
fix/redact-plumb-version-snapshot

Conversation

@aram-devdocs

Copy link
Copy Markdown
Owner

Summary

Closes #249. Stops the JSON envelope snapshots from churning on every release.

The two snapshots assert `"plumb_version": "0.0.X"` literally. The value comes from `env!("CARGO_PKG_VERSION")`, so v0.0.1 → 0.0.2 broke main CI (fixed in #248) and v0.0.2 → 0.0.3 would have broken release-please #250 the same way.

Fix

  • Enable insta's `filters` feature.
  • Redact `"plumb_version": "X.Y.Z"` to `"plumb_version": "[redacted]"` via a shared `Settings::add_filter` helper bound around the two json snapshot calls.
  • Update the two snapshot files to the redacted token.

Test plan

🤖 Generated with Claude Code

The two JSON envelope snapshots assert "plumb_version": "0.0.X"
literally. The value comes from env!("CARGO_PKG_VERSION"), so every
release version bump churns the snapshots and breaks CI on the
release-please PR (caught + patched in #248).

Adds insta's `filters` feature and redacts the version line via
`Settings::add_filter` so future releases stop drifting.

Closes #249.
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

I have everything I need. Here is the review.


PR #251test(format): redact plumb_version in JSON snapshots

Scope: 5 files, test-only change in plumb-format. No production code touched.


1. Determinism invariants

No violation. insta and regex are dev-dependencies; the filter runs only during snapshot assertion, never in the production formatter. The json and sarif formatters themselves are unchanged.

2. Workspace layering

No violation. All changes are confined to crates/plumb-format/tests/ and the workspace root Cargo.toml dev-dep list. No internal cross-crate dep changes, no unsafe added, no println!/eprintln!.

3. Error handling

No library code changed. No unwrap/expect added anywhere.

4. Test correctness

The insta pattern is idiomatic and correct:

  • Settings::clone_current() captures the thread-local settings baseline.
  • add_filter(regex, replacement) appends the filter.
  • .bind(|| ...) scopes it to the assertion closure — no global mutation.

The regex r#""plumb_version": "\d+\.\d+\.\d+(?:-[\w.+-]+)?""# is sufficient — it keys on the full JSON key-value pair so the match is specific. The pre-release class [\w.+-] is slightly permissive but won't produce false matches in practice.

Both .snap files correctly store the redacted token [redacted] — insta applies the filter before comparison, so the stored form must be the filtered form. ✓

5. Documentation

The comment on json_snapshot_settings() (crates/plumb-format/tests/format_snapshots.rs:79-80) explains the WHY in one line. No public API changed, so no rustdoc obligation.


Punch list

Nothing actionable. No blockers, no warnings.


Verdict: APPROVE

@aram-devdocs
aram-devdocs merged commit 0102a8d into main May 7, 2026
27 of 33 checks passed
@aram-devdocs
aram-devdocs deleted the fix/redact-plumb-version-snapshot branch May 7, 2026 08:52
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.

test(format): redact plumb_version in snapshots to avoid release churn

1 participant