Repository navigation
Conversation
Normalize combined actual field lines during matching while preserving quoted commas, indexed matchers, singleton headers, and pact data. Add regression coverage for repeated custom header expectations.
Split combined custom-header values consistently for list matching, regardless of field-line grouping. Apply the same normalization in the V2 request and response plans while preserving quoted and JSON values, and add regression coverage.
The legacy matcher and the V2 plan builder each decided on their own which headers may be split on commas. Legacy split Content-Type and multi-value headers such as Cache-Control, while V2 skipped both, so the same pact verified differently depending on the engine. repeated_headers::header_kind now maps a header name to Singleton, Parameterised, MultiValue or Custom, using the lists in pact_models. Both engines split only Custom headers, which removes the Content-Type divergence: ["text/plain", "text/html"] no longer matches a single "text/plain, text/html" line in either engine. Tests pin that Content-Type and Cache-Control stay unsplit. Assisted-by: Claude Code:claude-opus-5-5
RFC 9110 §5.3 makes repeated field lines equivalent to one line with the values joined by commas. A repeated custom header without matchers now joins both sides with ", " and compares the results, ignoring whitespace around commas outside quoted strings and empty list elements. Both engines share this logic through `match_repeated_header`. The previous change split only the actual field lines on commas. That broke repeated values that contain commas themselves: `["a, b", "c"]` against the same lines, two `X-Sunset` dates, or two `Link` lines whose URIs hold commas. Joining both sides keeps the combined, separate and mixed `X-Request` groupings matching. When the joined comparison fails, the header falls back to the per-line comparison it used before. A pass through the fallback logs a deprecation warning: per-line matching of repeated headers is deprecated, and a future release will compare only the joined value. A failed fallback reports one mismatch for the joined comparison. The legacy engine extracts the per-line body of `match_header_maps` into `match_header_lines`. The V2 plan replaces `header:split-values` with `header:match-repeated`. A custom header with one expected value gains a `header:repeated` check, so a single actual line keeps the existing plan node. Headers with matching rules keep the actual-only split until matchers move onto the joined value. Changed expectations: - `match_headers_returns_a_mismatch_if_the_header_values_have_different_lengths` now reports the joined mismatch (`Expected 'd' to be equal to 'd, e'`). - The V2 plan snapshots in `engine/tests/header_tests.rs` show the new actions. `match_headers_with_number_type_matching_rule` reports the legacy engine's matcher message for repeated actual lines. Assisted-by: Claude Code:claude-opus-5-5
A repeated custom header with scalar matchers (Regex, Type, Integer and the like) on its own path is now matched as RFC 9110 §5.3 describes it: the expected and actual field lines are joined with commas and the matchers run once against each joined value. List-aware rules (MinType, MaxType, MinMaxType, EachValue, ArrayContains) and headers with indexed rules go through the actual-only split_header_field_lines, with no fallback, until the list-element commit. When the joined value fails but the field lines pass one at a time, the header still matches and logs the per-line deprecation warning. The warning also suggests wrapping the user's rule in EachValue, rendered as JSON, as the way to keep per-value matching once only the joined value is compared. Two existing expectations change under the joined semantics, and the mismatch now describes the joined value instead of one line: - engine header_tests match_headers_with_number_type_matching_rule: "Expected '1111, two' to match an integer number". - headers::tests::match_header_with_a_values_matcher: a Values rule is not list-aware, so a reordered list reports one mismatch between the two joined values. A header whose expected list is empty skips the repeated-header node in the V2 plan and the matcher tolerates an empty expected list, so it cannot panic. Assisted-by: Claude Code:claude-opus-5-5
…chers
List-aware matchers (MinType, MaxType, MinMaxType, EachValue,
ArrayContains) and index-specific matchers now see the list elements of
a repeated custom header. The elements come from the joined actual
value, so `3, 4` / `567` and `3` / `4` / `567` both give three elements.
The splitter honours RFC 9110 §5.6.4: commas inside quoted strings do
not separate elements, and `\` escapes inside quotes are respected. It
trims each element and drops empty ones (§5.6.1). It has no `{}` or `[]`
nesting, so a JSON-looking value splits at its commas like any other.
`normalise_list` shares the same tokenizer.
An indexed matcher triggers the split when it sits at `$.<key>.<n>` or
`$.<key>[<n>]` with `n` below the larger of the expected count and the
element count. Wildcard element rules at `$.<key>[*]` or `$.<key>.*`
address every element, so they count as list rules too. This replaces a
bare path-length check that caught any deeper path.
When the element match fails, the matcher retries over the field lines
as received, which is the old behaviour. A pass there logs a warning.
The warning says whole-line matching is deprecated, gives the element
count a future release will see, and points at RFC 9110 §5.5's advice to
quote values that contain commas. This keeps MaxType(2) against
`x, y` / `z`, and EachValue over unquoted dates or Link values, passing.
The PR's interim `split_header_field_lines`, which tracked brace and
bracket nesting, is removed. No existing test expectation changed: the
JSON-valued compatibility cases carry no rules, so they still go through
plain comparison.
Assisted-by: Claude Code:claude-opus-5-5
Splitting a repeated header into list elements cut every comma outside a quoted string. Two registered headers carry commas of their own: - Link (RFC 8288 §3): a comma inside `<…>` belongs to the target URI, as in `<https://a.example/?fields=id,name>; rel="next"`. - Via (RFC 9110 §5.6.5): a comma inside a `(…)` comment belongs to the comment, and comments nest. `split_list_elements` now keeps those commas, matching the header name case-insensitively. Every other header reads `<`, `>`, `(` and `)` as ordinary characters. Delimiters inside quoted strings do not count, and an unbalanced `<` or `(` extends to the end of the value, as an unbalanced quote does. `normalise_list` stays name-agnostic. Plain comparison normalises both sides the same way, so a comma inside `<…>` that both share is harmless. User-Agent and Server are singletons (their product comments may hold commas) and are never split. The "each-value link fallback" case no longer needs the per-line fallback, so it becomes "each-value link" with no warning. New cases cover a combined Link line and a MaxType rule on Via. Assisted-by: Claude Code:claude-opus-5-5
…ones The ArrayContains and EachValue X-Id tests had their inputs rewritten to combined field lines, which dropped coverage of the separate-line form that master tested. Restore the original inputs and add `_with_combined_field_lines` variants carrying the combined-line inputs with the same assertions. Also remove the two length asserts at the end of match_headers_combined_custom_header_compatibility. match_headers receives clones, so they cannot fail. Assisted-by: Claude Code:claude-opus-5-5
The "Matching Headers" section still said values are compared after stripping whitespace following commas. Describe the current rules: repeated custom headers compare by their comma-joined values per RFC 9110 section 5.3, list-aware and index-specific matchers see split elements (respecting quotes, Link angle brackets and Via comments), other matchers see the joined value, per-line-only matches pass with a deprecation warning, and single-value, Accept/Content-Type and known multi-value headers are unchanged. Assisted-by: Claude Code:claude-opus-5-5
normalise_list split every header with the plain list grammar, so the fast path treated whitespace inside Link targets (<...>) and Via comments (...) as list separators. Values that differed only there compared as equal. Split with Grammar::for_header(name) instead, and add cases for Link, Via and Set-Cookie sent on separate lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lues A header with one value on each side and no matching rule was compared after splitting on every comma and trimming, so whitespace inside a Link <URI>, a Via comment or a quoted string was ignored (`<https://a/?x=1, 2>` matched `<https://a/?x=1,2>`). Use normalise_list, which only treats list-separating commas as insignificant, in the legacy matcher and in the V2 engine's multi-value header normalisation. The "quoted OWS fallback" case relied on that and now mismatches; the per-line deprecation warning test uses an unbalanced quote instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…scalar rule
A scalar rule on a repeated header reported only the joined mismatch
("Expected '1000, 1234, 9999ABC' to match '\d{1,4}'"), which doesn't say
which value failed. Report the per-line mismatches as well, and pass the
real list index to match_header_value in the matcher path instead of 0.
Fixes the V2 compatibility-suite scenario "Supports matchers for repeated
request headers (negative case)".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Runs CI for the stacked repeated-header matching changes, merged onto current master.
Included:
The PRs are stacked, so this branch is
masterplus a single merge of #14's head (7d06dcb), which contains the other two. The merge had no conflicts.cargo test -p pact_matching --lib headerspasses locally (122 tests).This PR is only for running CI. Don't merge it.
🤖 Generated with Claude Code