Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using "term" as query parameter is ignored in stub server #9

Open
5 tasks done
calvinbayer opened this issue Nov 4, 2022 · 2 comments
Open
5 tasks done

Using "term" as query parameter is ignored in stub server #9

calvinbayer opened this issue Nov 4, 2022 · 2 comments
Labels
bug Indicates an unexpected problem or unintended behavior upstream Indicates that an issue relates to an upstream problem (such as in pact-reference)

Comments

@calvinbayer
Copy link

Software versions

  • OS: macOS Monterey Version 12.0.1 (21A559)
  • Pact Node version: 10.17.6
  • Node Version: 16.13.0

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

I have defined a provider interaction like below. After executing that test and feeding the created PACT file into a stub server, I'd expect to get a successful response for any request in the form of /animals?id=<SOME_NUMBER>.

// Provider interaction in PACT Test
await provider.addInteraction({
  state: "there are animals",
  uponReceiving: "a request for a specific animal",
  withRequest: {
    path: "/animals",
    method: "GET",
    query: {
      id: term({
        generate: "123",
        matcher: "\\d+",
      }),
    },
  },
  willRespondWith: {
    status: 200,
    headers: {
      "Content-Type": "application/json",
    },
    body: {
      id: term({
        generate: "123",
        matcher: "\\d+",
      }),
      name: like("dog"),
    },
  },
});

// ...

// Starting a stub server
import { Stub } from "@pact-foundation/pact-node";

const pactStub = new Stub({ pactUrls: pactFiles, port: 4000, logLevel: "debug" });
await pactStub.start();

Actual behaviour

When the stub server boots, it will print the following error to the console

[email protected]: Pact Binary Error: WARN: Ignoring unsupported matching rules {"match"=>"regex", "regex"=>"\\d+"} for path $['query']$['id'][0]

and any request to /animals?id=<SOME_NUMBER> with SOME_NUMBER !== 123 will yield a 500 response. I have found this issue and this seems to have been a problem in the past that has been fixed already. However, I was not able to get it running with the latest version of @pact-foundation/pact-node.

Steps to reproduce

I've uploaded a minimal reproducible example here: https://github.com/calvinbayer/pact-stub-server-repro

Relevant log files

pact_debug_log.txt

@calvinbayer calvinbayer added the bug Indicates an unexpected problem or unintended behavior label Nov 4, 2022
@mefellows
Copy link
Member

Thanks for this, apologies for the radio silence - I'm not sure why it didn't get a response earlier.

This may be related to pact-foundation/pact-js#1063, but is more likely related to pact-foundation/pact-mock_service#140

@github-actions
Copy link
Contributor

👋 Thanks, this ticket has been added to the PactFlow team's backlog as PACT-768

@mefellows mefellows added the upstream Indicates that an issue relates to an upstream problem (such as in pact-reference) label Jul 12, 2023
@YOU54F YOU54F transferred this issue from pact-foundation/pact-js-core Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior upstream Indicates that an issue relates to an upstream problem (such as in pact-reference)
Projects
None yet
Development

No branches or pull requests

2 participants