Skip to content

Pact stub service throws error for query values with matching rules #140

@mefellows

Description

@mefellows

Pre issue-raising checklist

I have already (please mark the applicable with an x):

  • Read through the relevant docs at https://docs.pact.io
  • Upgraded to the latest version of the gem
  • Checked the CHANGELOG to see if the issue I am about to raise has been fixed
  • Created an executable example that demonstrates the issue using either a:
    • Dockerfile
    • Git repository with a Travis or Appveyor (or similar) build

Software versions

  • OS: e.g. Mac OSX 12.2.1
  • pact stub service: eg. v 3.9.0

Expected behaviour

Pact stub service can match on query strings

Actual behaviour

Error is thrown

Steps to reproduce

Given the following v2 pact file saved to /tmp/test.json:

{
  "provider": {
    "name": "sample-provider"
  },
  "consumer": {
    "name": "sample-consumer"
  },
  "interactions": [
    {
      "description": "a request to get a product",
      "request": {
        "method": "GET",
        "path": "/product/10",
        "query": "param=S",
        "matchingRules": {
          "$.query.param": {
            "match": "regex",
            "regex": "[A-Za-z0-9]{1,20}"
          }
        }
      },
      "response": {
        "status": 200
      }
    }
  ],
  "metadata": {
    "pactSpecification": {
      "version": "2.0.0"
    },
    "pact-jvm": {
      "version": "4.2.9"
    }
  }
}

Running the following command

pact-stub-service /tmp/test.json

Results in the error:

/opt/pact/lib/vendor/ruby/2.4.0/gems/pact-support-1.17.0/lib/pact/term.rb:31:in `initialize': Value to generate "["S"]" does not match regular expression /[A-Za-z0-9]{1,20}/ (Pact::Error)

Relevant log files

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions