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

[Stub server] Ignoring unsupported matching rules #475

Closed
5 tasks done
OskarLebuda opened this issue Jan 17, 2024 · 1 comment
Closed
5 tasks done

[Stub server] Ignoring unsupported matching rules #475

OskarLebuda opened this issue Jan 17, 2024 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior wontfix Indicates that work won't continue on an issue, pull request, or discussion

Comments

@OskarLebuda
Copy link

OskarLebuda commented Jan 17, 2024

Description

Hello everyone! ✌️
After generating a Pact and running the stub server, it fails to accept the syntax of the generated Pact, displaying the error message:

[10:18:42.822] ERROR (71098): pact-core@14.0.6: Pact Binary Error: WARN: Ignoring unsupported matching rules {"$.password"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}, "$.username"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}} for path ['body']

[10:18:42.822] DEBUG (71098): pact-core@14.0.6: WARN: Ignoring unsupported matching rules {"$.access_token"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}} for path ['body']

[10:18:42.822] ERROR (71098): pact-core@14.0.6: Pact Binary Error: WARN: Ignoring unsupported matching rules {"$.access_token"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}} for path ['body']

I've tried to use all available version like PactV3 and PactV4, additionally I've tried to use specification version 3 and 4. Every single time I've got an error described down below.

I would like to use StubServer to provide the mocks for my fronted app. I have created a reproducable git repository to illustrate the problem. All you need to do is clone this repo and run specified commands (see below)

Software versions

  • OS: MacOS Sonoma 14.2.1
  • Pact Node version:
    • @pact-foundation/pact: 12.1.2
    • @pact-foundation/pact-core: 14.0.6
  • Node Version: v18.19.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

Stub server runs correctly with generated pact.

Actual behaviour

Steps to reproduce

  • Clone repository
  • Run npm install (remember to use node >= 18)
  • Run npm run test
  • Run npm run start-stub

Result: Stub server shows error with ignoring unsupported matching rules

Relevant log files

[10:18:42.429] INFO (71098): pact-core@14.0.6: Creating Pact Stub with options: 
{"port":8080,"logLevel":"DEBUG","pactUrls":["/Users/olebuda/projects/pact/pacts"],"ssl":false,"cors":false,"host":"localhost"}
[10:18:42.432] DEBUG (71098): pact-core@14.0.6: Starting pact binary '/Users/olebuda/projects/pact/node_modules/@pact-foundation/pact-core/standalone/darwin-arm64-2.0.7/pact/bin/pact-stub-service', with arguments [/Users/olebuda/projects/pact/pacts --port 8080 --log-level DEBUG --host localhost]
[10:18:42.434] DEBUG (71098): pact-core@14.0.6: Created '/Users/olebuda/projects/pact/node_modules/@pact-foundation/pact-core/standalone/darwin-arm64-2.0.7/pact/bin/pact-stub-service' process with PID: 71176
[10:18:42.822] DEBUG (71098): pact-core@14.0.6: WARN: Ignoring unsupported matching rules {"$.password"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}, "$.username"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}} for path ['body']

[10:18:42.822] ERROR (71098): pact-core@14.0.6: Pact Binary Error: WARN: Ignoring unsupported matching rules {"$.password"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}, "$.username"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}} for path ['body']

[10:18:42.822] DEBUG (71098): pact-core@14.0.6: WARN: Ignoring unsupported matching rules {"$.access_token"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}} for path ['body']

[10:18:42.822] ERROR (71098): pact-core@14.0.6: Pact Binary Error: WARN: Ignoring unsupported matching rules {"$.access_token"=>{"combine"=>"AND", "matchers"=>[{"match"=>"type"}]}} for path ['body']

[10:18:42.823] DEBUG (71098): pact-core@14.0.6: INFO: Loading interactions from /Users/olebuda/projects/pact/pacts/LoginConsumer-LoginProvider.json
I, [2024-01-17T10:18:42.822114 #71176]  INFO -- : Registered expected interaction POST /api/login
D, [2024-01-17T10:18:42.822168 #71176] DEBUG -- : {
  "description": "a request to login user",
  "request": {
    "method": "POST",
    "path": "/api/login",
    "headers": {
      "Content-Type": "application/json"
    },
    "body": {
      "password": "password",
      "username": "username"
    }
  },
  "response": {
    "status": 200,
    "headers": {
      "Content-Type": "application/json"
    },
    "body": {
      "access_token": "some string"
    }
  },
  "metadata": null
}
mock WARN: Please note: we are tracking events anonymously to gather important usage statistics like Pact-Ruby version and operating system. To disable tracking, set the 'PACT_DO_NOT_TRACK' environment variable to 'true'.
INFO  WEBrick 1.8.1

[10:18:42.823] DEBUG (71098): pact-core@14.0.6: INFO  ruby 3.2.2 (2023-03-30) [arm64-darwin22]

[10:18:42.826] DEBUG (71098): pact-core@14.0.6: INFO  WEBrick::HTTPServer#start: pid=71176 port=8080

[10:19:03.738] INFO (71098): pact-core@14.0.6: Removing all Pact stubs.
@OskarLebuda OskarLebuda added the bug Indicates an unexpected problem or unintended behavior label Jan 17, 2024
@mefellows
Copy link
Member

The current stub server only supports up to version 2 of the spec. I'd recommend using this stub server instead: https://github.com/pact-foundation/pact-stub-server

We could consider replacing the current ruby based one with the one above in this package, but I'm also still weighing up whether in the next major version we should keep the binaries or not (I'm leaning toward not, as the CLI can be downloaded independently and the rust binaries are not command-for-command compliant, meaning if we replace the ruby ones there will be a de-facto breaking change anyway).

@mefellows mefellows added the wontfix Indicates that work won't continue on an issue, pull request, or discussion label Jan 17, 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 wontfix Indicates that work won't continue on an issue, pull request, or discussion
Projects
None yet
Development

No branches or pull requests

2 participants