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

Pact PHP > Compatibility Suite: Error "Matching rule JSON [] is not correctly formed" #360

Closed
tienvx opened this issue Jan 19, 2024 · 1 comment

Comments

@tienvx
Copy link
Contributor

tienvx commented Jan 19, 2024

There are 1 errors that make 2 scenarios failed when updating to 0.4.13:

  • compatibility-suite/pact-compatibility-suite/features/V3/http_provider.feature:10
  • compatibility-suite/pact-compatibility-suite/features/V3/http_provider.feature:25
Failures:

1) Failed to load pact - Failed to load pact '/home/runner/work/pact-php/pact-php/compatibility-suite/tests/Constant/../../pacts/c-p.json' - Matching rule JSON [] is not correctly formed

Here is the pact file (for the http_provider.feature:25) look like:

{
  "consumer": {
    "name": "c"
  },
  "interactions": [
    {
      "description": "Interaction 1",
      "request": {
        "method": "GET",
        "path": "/one"
      },
      "response": {
        "body": {
          "one": "a",
          "two": "b"
        },
        "headers": {
          "Content-Type": "application/json",
          "X-TEST": "1"
        },
        "matchingRules": {
          "body": [],
          "header": {
            "x-test": {
              "combine": "AND",
              "matchers": [
                {
                  "match": "regex",
                  "regex": "\\d{1,4}"
                }
              ]
            }
          },
          "status": []
        },
        "status": 200
      },
      "providerStates": [
        {
          "name": "A user exists",
          "params": {
            "name": "Bob",
            "age": 22
          }
        }
      ]
    }
  ],
  "metadata": {
    "pactRust": {
      "ffi": "0.4.13",
      "models": "1.1.16"
    },
    "pactSpecification": {
      "version": "3.0.0"
    }
  },
  "provider": {
    "name": "p"
  }
}

Here is the one for http_provider.feature:10 (only the providerStates part is different):

{
  "consumer": {
    "name": "c"
  },
  "interactions": [
    {
      "description": "Interaction 1",
      "request": {
        "method": "GET",
        "path": "/one"
      },
      "response": {
        "body": {
          "one": "a",
          "two": "b"
        },
        "headers": {
          "Content-Type": "application/json",
          "X-TEST": "1"
        },
        "matchingRules": {
          "body": [],
          "header": {
            "x-test": {
              "combine": "AND",
              "matchers": [
                {
                  "match": "regex",
                  "regex": "\\d{1,4}"
                }
              ]
            }
          },
          "status": []
        },
        "status": 200
      },
      "providerStates": [
        {
          "name": "State One",
          "params": []
        },
        {
          "name": "State Two",
          "params": []
        }
      ]
    }
  ],
  "metadata": {
    "pactRust": {
      "ffi": "0.4.13",
      "models": "1.1.16"
    },
    "pactSpecification": {
      "version": "3.0.0"
    }
  },
  "provider": {
    "name": "p"
  }
}

Here is the pipeline:
https://github.com/tienvx/pact-php/actions/runs/7580078431/job/20645308626#step:5:55

@tienvx
Copy link
Contributor Author

tienvx commented Jan 19, 2024

It's my fault. It should be:

"matchingRules": {
          "body": {},
          "status": {}
        },

not

"matchingRules": {
          "body": [],
          "status": []
        },

@tienvx tienvx closed this as completed Jan 19, 2024
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

No branches or pull requests

1 participant