Skip to content

fix: ProviderStateGenerator expression shorthand support for query, header, and body (FFI)#532

Draft
Copilot wants to merge 4 commits into
masterfrom
copilot/fix-provider-state-generator
Draft

fix: ProviderStateGenerator expression shorthand support for query, header, and body (FFI)#532
Copilot wants to merge 4 commits into
masterfrom
copilot/fix-provider-state-generator

Conversation

Copy link
Copy Markdown

Copilot AI commented May 25, 2026

The {"expression":"${var}","value":"example"} shorthand format for ProviderStateGenerator was silently broken for query parameters, headers, and bodies — only path worked. For bodies, the full JSON object was stored verbatim instead of extracting the example value; for query/headers, the example value was extracted correctly but no generator was configured.

Changes

  • bodies.rsprocess_object: Add branch for objects with expression but no pact:matcher:type. Calls Generator::from_map("ProviderState", ...), registers the generator, and returns the value field as the example.
  • handles.rsfrom_integration_json_v2: Same treatment for non-body values. Extracted the repeated if path_or_status { path.parent()... } pattern into effective_path to eliminate three near-identical blocks.
  • IntegrationJson.md: Documents both formats explicitly, clarifying the shorthand configures no matching rule.

Usage

Both formats are now supported across all interaction parts:

// Shorthand — generator only, no matching rule
{ "expression": "${accountNumber}", "value": "100" }

// Full — generator + matching rule
{ "value": "100", "pact:matcher:type": "type", "pact:generator:type": "ProviderState", "expression": "${accountNumber}" }

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.google-analytics.com
    • Triggering command: /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.0cifm40e9n7lso8a96xtiaars.1h2mas3.rcgu.o /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.0jduurjg32c9hz1odmlkqnb90.1h2mas3.rcgu.o /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.0jgm4wupv2qnfqlwjtv192rms.1h2mas3.rcgu.o /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.0l2n31o5f0vv1wdfytfwzjtds.1h2mas3.rcgu.o /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.0mnh80qsyc2b854gc8nevx3ju.1h2mas3.rcgu.o /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.0wnhykf4hdsi6hxhjrm6qb9ni.1h2mas3.rcgu.o /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.11w7lisbnykqfms5f4lzo5y87.1h2mas3.rcgu.o /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.12jojkzxzbtqc8s07ifgtirth.1h2mas3.rcgu.o /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783�� /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.11w7lisbnykqfms5f4lzo5y87.03lvett.rcgu.o /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.12jojkzxzbtqc8s07ifgtirth.03lvett.rcgu.o f/aw�� g/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/build/aws-lc-scc g/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/build/aws-lc-s-m64 g/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/rustchOhC69/symbols.o g/build/aws-lc-scc g/build/aws-lc-s-m64 g/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/rustc74RF/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.055a4tmiboq33ztlpitmr61mv.1h2mas3.rcgu.o g/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.0693wwdgfq1vm2d2m56z2t0lp.1h2mas3.rcgu.o (dns block)
    • Triggering command: /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c 0bzbvvm6dpkdu2ro9aatowjsk.1dqaq2c.rcgu.o 0cr6os003m3fbkqi1y3xftqcd.1dqaq2c.rcgu.o 0lgswwy2ino2dgjg01ddqfb8p.1dqaq2c.rcgu.o 0mbymqz4xzv9qpgpzgder4k20.1dqaq2c.rcgu.o Oa/symbols.o 1cf18b17b1d81.04qrp1n3mvjo6xv2vr86izxx0.0ht63s8.rcgu.o 1cf18b17b1d81.05byn37z5c935ymoq1jqhmq4i.0ht63s8.rcgu.o 1cf18b17b1d81.07j6xjnyzmn2m7kx3es45oxnu.0ht63s8.rcgu.o 1cf18b17b1d81.09nq0brzpccczm1jkhmaybugq.0ht63s8.rcgu.o 1cf18b17b1d81.0annzys4445gos8ngapgyvels.0ht63s8.rcgu.o 1cf18b17b1d81.0ccjg5kexagklgvy99spr06jr.0ht63s8.rcgu.o 1cf18b17b1d81.0j6xprtxe0p48l5spzwt9ddx7.0ht63s8.rcgu.o 1cf18b17b1d81.0lfgbzsshcvdrdq9j1yf3dny8.0ht63s8.rcgu.o 1cf18b17b1d81.0lusoyi8avqm2dganwy2296t4.0ht63s8.rcgu.o 1cf18b17b1d81.0o3gvmc5dy2j4xlv6lqetwgaf.0ht63s8.rcgu.o 1cf18b17b1d81.0stna28rz95vq4qiqv03op0ta.0ht63s8.rcgu.o 1cf18b17b1d81.0yeq1ia8h5gap6wnh0ihh8aot.0ht63s8.rcgu.o 1cf18b17b1d81.0ynf9xpc4r4sdxivkd0i0dk1m.0ht63s8.rcgu.o 1cf18b17b1d81.0z37cflm40kzqq5q8l3at0vaa.0ht63s8.rcgu.o (dns block)
    • Triggering command: `/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c /home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c --target x86_64-REDACTED-linux-gnu g/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi--c g/bu�� g/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/rustc g/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi--vV -1949cf8c6b5b557/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.11w7lisbnykqfms5f4lzo5y87.1fjyc1o.rcgu.o -1949cf8c6b5b557git -1949cf8c6b5b557show -1949cf8c6b5b5579f100787cbc4e390a1e0f3701fe2084f3f4924f8:rust/pact_ffi/src/mock_server/bodies.rs -1949cf8c6b5b557/home/REDACTED/work/pact-reference/pact-reference/rust/target/debug/deps/pact_ffi-e783aee9d449c50c.12jojkzxzbtqc8s07ifgtirth.1h2mas3.rcgu.o -194�� rust/target/debug/build/aws-lc-s/home/REDACTED/work/pact-reference/pact-reference/rust/target/debulsb_release for query, header, and body (FFI)

When a JSON object contains an expression key (without pac-a /lib/jspawnhelper rust/target/debu/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo rust/target/deburustc rust/target/debu-Z /lib/jspawnhelpeunstable-options (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 3 commits May 25, 2026 04:44
…uery, header, and body (FFI)

When a JSON object contains an `expression` key (without `pact:matcher:type`), it is now
treated as a ProviderStateGenerator shorthand. The `value` field is extracted as the example
value, and a ProviderStateGenerator is configured with the expression.

This fixes the issue where `{"expression":"${var}","value":"100"}` was not working for
query parameters, headers, and bodies - only the path case worked before.

Agent-Logs-Url: https://github.com/pact-foundation/pact-reference/sessions/fb2a6dd6-ef83-46ac-af88-f8edd5445fc0

Co-authored-by: mefellows <53900+mefellows@users.noreply.github.com>
…ve redundant condition in bodies.rs

Agent-Logs-Url: https://github.com/pact-foundation/pact-reference/sessions/fb2a6dd6-ef83-46ac-af88-f8edd5445fc0

Co-authored-by: mefellows <53900+mefellows@users.noreply.github.com>
…son.md; add warn log for missing value

Agent-Logs-Url: https://github.com/pact-foundation/pact-reference/sessions/fb2a6dd6-ef83-46ac-af88-f8edd5445fc0

Co-authored-by: mefellows <53900+mefellows@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ProviderStateGenerator path matching for query strings fix: ProviderStateGenerator expression shorthand support for query, header, and body (FFI) May 25, 2026
Copilot AI requested a review from mefellows May 25, 2026 04: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.

ProviderStateGenerator only supports path matching via IntegrationJson (FFI)

2 participants