Skip to content

feat: matching rules and generators for each header and query value (indexed keys) - #21

Draft
YOU54F wants to merge 27 commits into
masterfrom
feat/indexed-header-query-rules
Draft

YOU54F wants to merge 27 commits into
masterfrom
feat/indexed-header-query-rules

Conversation

@YOU54F

@YOU54F YOU54F commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Draft: needs an RFC and a V4 spec change. Stacked on feat/ffi-remove-header, so the first 3 commits belong to that PR. The scenarios are in YOU54F/pact-compatibility-suite#3.

Commits

fix(matching): don't report a body type mismatch for a sniffed actual content type

When the actual request or response has no Content-Type header, its content
type is only a guess from the body bytes (the mock server stores that guess on
the body). Compare the body using the expected content type instead of
reporting a BodyTypeMismatch, so a binary body sent without a header can
match an expected application/octet-stream body.

Refs pact-foundation/pact-go#263

feat(ffi): add pactffi_remove_header to remove a header and its rules

Removes a header (case-insensitively) from the request or response of an
interaction, along with its matching rules and generators. This lets a
wrapper drop the Content-Type header that pactffi_with_body and
pactffi_with_binary_body add by default, while the body keeps its content
type. Before V4 the body has nowhere else to record its type, so removing
Content-Type from a part with a non-text body is refused.

Refs pact-foundation/pact-go#263

test(compatibility-suite): steps to remove a header from the expected and received requests

fix(models): keep matching rules and generators for each header and query value

Matching rules and generators added for a specific value of a repeated
header or query parameter (e.g. via pactffi_with_header_v2 with index > 0)
are keyed as $.name[n]. When writing V3/V4 pact JSON, to_v3_json and the
generator serialisation reduced the path to first_field(), so every index
collapsed onto the bare name and only one (random) rule survived.

Indexed rules are now written with their full path, e.g. $['X-Request'][1].
A lone [0] is still written as the bare name, so existing pact files are
unchanged. Reading maps $-prefixed [Root, Field, Index] keys back to
indexed paths; all other keys keep their existing meaning.

fix: an indexed header or query rule overrides the rule for the name

select_best_matcher returned the first rule list from a HashMap for the
header and query categories, so when both a and $.a[1] matched a value
the rule used was random. It now selects the longest matching key.

match_header_value checked the rule for the name before the indexed rule,
and the multi-value list callback always passed index 0. It now looks up
the indexed path, which also matches the rule for the name, and passes the
value's index.

chore(compat): support query and headers columns in V4 HTTP matching steps

feat: apply header and query generators to each value, with indexed keys

A generator for a header or query parameter name now applies to every value,
and header names are matched without regard to case. A generator key with a
value index ($.name[1] or $['name'][1]) applies only to that value and runs
after the generator for the name; an index for a value that is not there is
ignored. The compatibility suite steps gain query and headers columns for the
generator scenarios.

test: a query generator for a missing parameter generates a single value

🤖 Generated with Claude Code

ChangkeunJ and others added 27 commits October 26, 2026 18:43
pact_verifier builds pact_matching with default-features = false and
never enabled form_urlencoded, so apply_body_generators took the
#[cfg(not(feature = "form_urlencoded"))] branch and sent form bodies to
the provider as recorded. Add a form_urlencoded feature to
pact_verifier, put it in the defaults and pass it through from
pact_verifier_cli, with a test that runs generate_request over the form
request from the issue.

Closes pact-foundation#588
…orm-urlencoded-generators

fix(pact_verifier): apply generators to form-urlencoded request bodies
…act_matching

chore(pact_matching): release v2.2.0
…act_models

chore(pact_models): release v1.3.18
…act_verifier

chore(pact_verifier): release v1.6.0
…_mock_server-v2.2.7

chore(deps): update pact_mock_server v2.2.7
…act_verifier_cli

chore(pact_verifier_cli): release v1.5.0
…ocker fetch stage (pact-foundation#608)

The fetch stage had no WORKDIR, so the tarball unpacked into / and
`install pact-verifier /pact-verifier` failed with "are the same file",
breaking the Docker image publish for v1.5.0.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Nothing exercised the XSLT step of the HTML report, so an xrust
upgrade could change its output unnoticed. The snapshot pins the
output of the default stylesheet for a failing result with a notice
and a passing interaction.

Assisted-by: Claude Code:claude-opus-5-5
xrust broke its API in two minor releases, and the old requirement
`xrust = "2.0.3"` admitted both:

- 2.3.0 gave `ParseError::MissingNameSpace` the fields `prefix`,
  `nsuri` and `message`.
- 2.4.0 renamed `StaticContextBuilder::fetcher` to `external`. The
  callback for external resources now takes `&External` and returns
  `Sequence<N>`, both in the builder and in `xslt::from_document`.

Any build that resolved dependencies afresh, such as `cargo install`
without `--locked` or a downstream lockfile update, picked up 2.4.1 and
failed to compile the report module. The requirement is now 2.4.1, the
first release with the current API.

The HTML report snapshot is unchanged under 2.4.1.

Assisted-by: Claude Code:claude-opus-5-5
… content type

When the actual request or response has no Content-Type header, its content
type is only a guess from the body bytes (the mock server stores that guess on
the body). Compare the body using the expected content type instead of
reporting a BodyTypeMismatch, so a binary body sent without a header can
match an expected application/octet-stream body.

Refs pact-foundation/pact-go#263

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Removes a header (case-insensitively) from the request or response of an
interaction, along with its matching rules and generators. This lets a
wrapper drop the Content-Type header that pactffi_with_body and
pactffi_with_binary_body add by default, while the body keeps its content
type. Before V4 the body has nowhere else to record its type, so removing
Content-Type from a part with a non-text body is refused.

Refs pact-foundation/pact-go#263

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and received requests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uery value

Matching rules and generators added for a specific value of a repeated
header or query parameter (e.g. via pactffi_with_header_v2 with index > 0)
are keyed as $.name[n]. When writing V3/V4 pact JSON, to_v3_json and the
generator serialisation reduced the path to first_field(), so every index
collapsed onto the bare name and only one (random) rule survived.

Indexed rules are now written with their full path, e.g. $['X-Request'][1].
A lone [0] is still written as the bare name, so existing pact files are
unchanged. Reading maps $-prefixed [Root, Field, Index] keys back to
indexed paths; all other keys keep their existing meaning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
select_best_matcher returned the first rule list from a HashMap for the
header and query categories, so when both `a` and `$.a[1]` matched a value
the rule used was random. It now selects the longest matching key.

match_header_value checked the rule for the name before the indexed rule,
and the multi-value list callback always passed index 0. It now looks up
the indexed path, which also matches the rule for the name, and passes the
value's index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…steps

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A generator for a header or query parameter name now applies to every value,
and header names are matched without regard to case. A generator key with a
value index ($.name[1] or $['name'][1]) applies only to that value and runs
after the generator for the name; an index for a value that is not there is
ignored. The compatibility suite steps gain query and headers columns for the
generator scenarios.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 1acfa1ec..3a9253b8

3a9253b8 feat: add V4 scenario for a query generator for a missing parameter
da365e5f feat: add V4 scenarios for generators on each header and query value
38d5439b feat: V4 scenarios for matching rules on each header and query value
a20066c1 feat(V4): scenarios for a typed body without a Content-Type header
dd08122c chore(ci): remove stale internal workflows
b967036e chore(ci): standardize renovate config
5cc2857f chore(deps): update pact-foundation/.github digest to f8fd527
a5b21328 chore(deps): update pact-foundation/.github digest to 1633eb6
b03375f0 chore(deps): pin pact-foundation/.github action to 3a9ea59

git-subtree-dir: compatibility-suite/pact-compatibility-suite
git-subtree-split: 3a9253b85625eb2daebcfa5b4671f0a5de1d1e18
…rom YOU54F/pact-compatibility-suite feat/v4-body-content-type
@YOU54F
YOU54F force-pushed the feat/indexed-header-query-rules branch from 50131a3 to 270db93 Compare November 26, 2026 15: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.

3 participants