feat: add requestTransform for deterministic matching and recording#79
Merged
feat: add requestTransform for deterministic matching and recording#79
Conversation
Normalizes requests before matching and recording to handle dynamic data (timestamps, UUIDs, session IDs) in prompts. When set, string matching switches from includes to exact equality to prevent false positives from shortened keys. Applied across all 15 provider handlers + recorder. 16 new tests. Based on the design by @iskhakovt in #63, rebuilt on the 1.7.0 codebase.
commit: |
Contributor
Author
|
Full credit to @iskhakovt, this is just his work rebuilt on top of the new release of |
This was referenced Apr 6, 2026
Merged
jpr5
added a commit
that referenced
this pull request
Apr 6, 2026
## v1.8.0 ### Features - `requestTransform` — deterministic matching and recording (#79, based on @iskhakovt's #63) - Reasoning/thinking for OpenAI Chat Completions (#62 by @erezcor) - Reasoning for Gemini, Bedrock, Bedrock Converse, Ollama (#81) - Web search events for OpenAI Responses API (#62) ### Fixes - Migration page health checks (#80) - Stream collapse reasoning event handling - GitHub URLs, OG image, drift docs reframe ### Versions bumped - `package.json` → 1.8.0 - `plugin.json` → 1.8.0 - `marketplace.json` → ^1.8.0 - `Chart.yaml` appVersion → 1.8.0 - `aimock-pytest/_version.py` AIMOCK_VERSION → 1.8.0 - `CHANGELOG.md` — full v1.8.0 + retroactive v1.7.0 entries 2,090 tests across 59 files. Build clean.
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.
Summary
Adds
requestTransformtoMockServerOptions— a function that normalizes requests before both matching and recording, solving the problem of dynamic data (timestamps, UUIDs, session IDs) causing fixture mismatches on replay.Recording: saves the transformed match key — no timestamps in fixture.
Matching: transforms incoming request before comparison — same clean key.
When
requestTransformis set, string matching switches fromincludes(substring) to===(exact equality). Without a transform, existingincludesbehavior is preserved (backward compatible).Changes
types.ts: AddrequestTransformtoMockServerOptionsandHandlerDefaultsrouter.ts: Optional 4th param onmatchFixture, exact match when transform setserver.ts: Thread transform into defaultsrecorder.ts: Apply transform before match key extractiondefaults.requestTransformtomatchFixturedocs/record-replay.html: Document the feature with use case and exampleAttribution
Based on the design by @iskhakovt in #63, rebuilt cleanly on the 1.7.0 codebase. The original PR had 100 commits and was conflicting after the v1.7.0 rebrand — this is a fresh implementation of the same concept.
Test plan
npx vitest run— 2064 tests pass (58 files)npx tsc --noEmit— cleanincludesbehavior unchanged