Repository navigation
Conversation
|
Hey dude! Finally got some time to look at this, set up a little harness to test it against the various ffi consumers, findings are below. It was written by Claude FYI Downstream validation of #568 + #584I built
The FFI surface is unchanged ( Verdict
Scenarios✅ = behaved as expected, ❌ = didn't.
H1–H5 were run in pact-go, pact-js-core and pact-python, with identical results in all three. H6 and H8 were run in pact-go, and later as per-consumer tests in all six consumers.
Consumer suites
After the consumer-side fixes listed under "Follow-ups", a final pr584 rerun was green everywhere: pact-net 173/0, pact-go 251/0 + 8/0, pact-js 314/314, pact-js-core 101 pass / 1 skipped, pact-python 699 pass, pact-php 996 OK, pact-ruby 9/0, pact-ruby-ffi 16/0. Deprecation warning
Gap found: header normalisation ignores the header's grammarWith no matching rules, header values were split without the header's own grammar. So a whitespace change inside a
Fix: YOU54F#14 (link, commits de449d7 and fd5ed24, based on this branch).
Behaviour change for single values: Happy for it to be cherry-picked here. Separate, pre-existing: per-index header/query matchers are lost when the pact file is writtenThis isn't caused by #568 or #584, but #584 makes it more visible.
There's a draft fix on the fork, YOU54F#15 (link). It writes indexed keys as I tested pact-jvm (master): it doesn't support per-value header or query rules in any key layout. The details are in the drafted issue, which I'll raise separately. Suggested path
Follow-ups in the consumers (to land with the 0.5.13 upgrade)Each consumer has repeated-header tests (H1–H8b). These consumer API gaps came up and are fixed in draft PRs on my forks:
Without a way to read the mock server logs, those consumers couldn't assert the deprecation warning. The pact-php and pact-net changes add interface methods, so they'll need release notes. |
|
I've tested a merge of the three stacked pr's against CI which is all green, and also tested locally against the client libs in the linked draft pr's |
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
b20acd8 to
5110e49
Compare
138fc40 to
c6e88d1
Compare
|
merged in #602 |
Warning
I pushed this late in the day. I (Josh) have not vetted all of it yet. Treat it as a draft for discussion.
This is a review PR for #568. It targets
fix/repeated-headers, so the diff shows only my changes on top of yours. Each commit addresses one behaviour, so you can cherry-pick the ones you want and drop the rest. Take it or leave it.The commits read best one at a time: open the Commits tab and step through them. Each commit message explains its reasoning in more depth than this summary.
Approach
RFC 9110 §5.3 defines repeated field lines as equivalent to one line joined with
", ". Joining is always safe. Splitting needs the header's grammar, which Pact doesn't know for custom headers. #568 splits only the actual values, so a repeated header whose values contain commas (dates,LinkURIs) no longer matches itself. These commits join both sides instead, and split only where a matcher needs list elements.Nothing that passes on master fails here, in either engine. Where only master's per-line comparison matches, the header still passes and logs a deprecation warning, which suggests the matcher to use instead.
Commits
header_kindpredicate, used by both the legacy and the V2 engine. Only custom headers get the new behaviour.Content-Typeand the known multi-value headers stop being split in legacy, which matches master and V2.Regex,Type, number matchers and the like seea, bas one value. If only the per-line match passes, the warning suggests wrapping the rule inEachValue.MinType,MaxType,MinMaxType,EachValue,ArrayContains, indexed and[*]rules see elements, split on commas outside quoted strings. This removessplit_header_field_lines. This is the first commit that is safe against master. Stopping at commit 2 or 3 keeps fix(matching): match combined headers against repeated expectations #568's behaviour for list matchers over values containing commas.LinkandViagrammars. A comma inside<…>(RFC 8288) or a nested(…)comment (RFC 9110 §5.6.5) doesn't split.ArrayContainsandEachValueX-Idtests, keeps your combined-line versions beside them, and drops two asserts that couldn't fail.Known gaps
wasm32-wasip2locally. CI covers it.