question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After update: Provider state parameters not rendered into contract JSON for request path parameters

See original GitHub issue

Software versions

  • OS: Mac OSX 12.5
  • Pact Node version: @pact-foundation/pact-core@13.7.7
  • Node Version: v16.15.1
  • Other Versions: Pulled as dependency of @pact-foundation/pact@10.1.1

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

When writing a consumer test, where the setup uses a fromProviderState() matcher on a request path parameter, the resulting Pact JSON file should contain a generator and matchingRule for this provider state parameter.

Actual behaviour

After updating from @pact-foundation/pact@10.0.2 to @pact-foundation/pact@10.1.1, the Pact JSON file does not contain a corresponding generator/matchingRule.

This is only true for path parameters - for provider state parameters from query parameters or body parameters, this still works as expected.

Steps to reproduce

E.g. with the provider-state-injected example (https://github.com/pact-foundation/pact-js/tree/master/examples/v3/provider-state-injected):

  • Run the consumer contract test & save the resulting pact JSON file
  • Upgrade the pact dependency in the package.json from 10.0.2 to 10.1.1
  • Run the consumer contract test again & compare the resulting JSON files

This is what I get:

diff TransactionService-AccountService-v10.0.2.json TransactionService-AccountService-v10.1.1.json
329,344c329,330
<         "generators": {
<           "path": {
<             "expression": "/data/${uuid}",
<             "type": "ProviderState"
<           }
<         },
<         "matchingRules": {
<           "path": {
<             "combine": "AND",
<             "matchers": [
<               {
<                 "match": "type"
<               }
<             ]
<           }
<         },
---
>         "generators": {},
>         "matchingRules": {},
381c367
<       "version": "10.0.2"
---
>       "version": "10.1.1"
384,385c370,371
<       "ffi": "0.2.4",
<       "models": "0.3.1"
---
>       "ffi": "0.3.5",
>       "models": "0.4.1"

Relevant log files

None

I hope this is the right repo to open this issue - if it should go to pact-js instead, let me know and I can open it there instead 🙇

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
j-beyercommented, Sep 5, 2022

Can also confirm from our side that it works again 👍 Thanks for the quick fix!

1reaction
mefellowscommented, Aug 30, 2022

13.7.9 is now out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Injecting values from provider states - Pactflow
Using a value from the provider state​​ To solve this problem we can inject the value from the provider state callback. The callback...
Read more >
`router.query` returns undefined parameter on first render in ...
When I have the following code and visit /pages/profile/foo , the page gets rendered twice and the first time router.query.user is undefined ...
Read more >
Painless contract testing with Pactflow - kreuzwerker
Using the OpenApiValidationFilter in its full scope, we can validate the request path, the request object and response object.
Read more >
JSON:API — Latest Specification (v1.1)
When processing a JSON:API response document, clients MUST ignore any parameters other than ext and profile parameters in the server's Content- ...
Read more >
Common parameters—ArcGIS REST APIs
Item parameters correspond to properties of an item that are available to update on the Add Item and Update Item operations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found