Skip to content

Specs - Scrub X-Mailgun-Key-Id from VCR cassettes - #403

Merged
alex-leb merged 1 commit into
masterfrom
chore/scrub-cassette-key-ids
Oct 14, 2026
Merged

alex-leb merged 1 commit into
masterfrom
chore/scrub-cassette-key-ids

Conversation

@alex-leb

Copy link
Copy Markdown
Contributor

Mailgun returns the ID of the key used for a request in the X-Mailgun-Key-Id response header. That ID is the last part of the API key itself (<secret>-<key id>), and the existing cassettes recorded it unfiltered, so they exposed the tail of the keys that recorded them. The secret part of a key is never in the header.

  • Replace the 5 recorded key IDs (73 header values across 11 cassettes) with <KEY_ID>. Only that header changes: requests, response bodies and request matching are untouched.
  • Add a VCR before_record hook in spec_helper.rb that replaces the header (any case) on future recordings, alongside the existing key, auth and domain filters.

Full suite, run without credentials: 413 examples, 0 failures, and no cassette changes during the run. The hook was checked separately against a recorded-style interaction.

The keys these IDs belong to may be worth rotating, since their IDs have been public in the repo's history.

The key ID Mailgun returns in the X-Mailgun-Key-Id header is the last
part of the API key (<secret>-<key id>), so recorded cassettes exposed
the tail of the keys that recorded them.

- Replace the 5 key IDs (73 header values in 11 cassettes) with
  <KEY_ID>; requests, response bodies and matching are unchanged
- Add a VCR before_record hook that replaces the header on future
  recordings
@alex-leb
alex-leb merged commit c64bfde into master Oct 14, 2026
8 checks passed
@alex-leb
alex-leb deleted the chore/scrub-cassette-key-ids branch October 14, 2026 16:49
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