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

WARNING: Pact file has no interactions #359

Closed
tienvx opened this issue Jan 17, 2024 · 8 comments
Closed

WARNING: Pact file has no interactions #359

tienvx opened this issue Jan 17, 2024 · 8 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@tienvx
Copy link
Contributor

tienvx commented Jan 17, 2024

How to reproduce this issue:

  • git clone --branch bug-pact-file-no-interactions git@github.com:tienvx/pact-php.git
  • cd pact-php/example/matchers/consumer
  • phpunit
  • cd ../provider
  • phpunit

This issue only happen with 0.4.12. It doesn't happen with 0.4.11

Here is the commit that can explain what happen:

diff --git a/composer.json b/composer.json
index c83557c9..7db191e6 100644
--- a/composer.json
+++ b/composer.json
@@ -103,12 +103,12 @@
     "extra": {
         "downloads": {
             "pact-ffi-headers": {
-                "version": "0.4.11",
+                "version": "0.4.12",
                 "url": "https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v{$version}/pact.h",
                 "path": "bin/pact-ffi-headers/pact.h"
             },
             "pact-ffi-lib": {
-                "version": "0.4.11",
+                "version": "0.4.12",
                 "variables": {
                     "{$prefix}": "PHP_OS_FAMILY === 'Windows' ? 'pact_ffi' : 'libpact_ffi'",
                     "{$os}": "PHP_OS === 'Darwin' ? 'osx' : strtolower(PHP_OS_FAMILY)",
diff --git a/example/matchers/pacts/matchersConsumer-matchersProvider.json b/example/matchers/pacts/matchersConsumer-matchersProvider.json
index a9f8dce8..c2686643 100644
--- a/example/matchers/pacts/matchersConsumer-matchersProvider.json
+++ b/example/matchers/pacts/matchersConsumer-matchersProvider.json
@@ -29,21 +29,21 @@
             ]
           },
           "query": {
-            "$.pages": {
+            "locales[]": {
               "combine": "AND",
               "matchers": [
                 {
                   "match": "regex",
-                  "regex": "\\d+"
+                  "regex": "^[a-z]{2}-[A-Z]{2}$"
                 }
               ]
             },
-            "$['locales[]']": {
+            "pages": {
               "combine": "AND",
               "matchers": [
                 {
                   "match": "regex",
-                  "regex": "^[a-z]{2}-[A-Z]{2}$"
+                  "regex": "\\d+"
                 }
               ]
             }
@@ -591,9 +591,9 @@
   ],
   "metadata": {
     "pactRust": {
-      "ffi": "0.4.11",
+      "ffi": "0.4.12",
       "mockserver": "1.2.4",
-      "models": "1.1.12"
+      "models": "1.1.14"
     },
     "pactSpecification": {
       "version": "4.0"
@rholshausen
Copy link
Contributor

Hmm, this is odd. Let me check the commit history to see what could be causing this.

@rholshausen rholshausen added the bug Indicates an unexpected problem or unintended behavior label Jan 18, 2024
@tienvx
Copy link
Contributor Author

tienvx commented Jan 19, 2024

I think locales[] in the pact file causing this issue.

This query syntax locales[]=first&locales[]=second (PHP is using this syntax as multiple values) is mapped to "$['locales[]']": {"matchers": ...} in pact file in 0.4.11 and it's supported, now it's mapped to "locales[]": {"matchers": ...} and look like it's not supported any more -> result in the 'warning' above

@rholshausen
Copy link
Contributor

But that should never result in the interaction being ignored and an empty Pact returned. It should either ignore just that matching rule and load the result or return an error for the whole process.

I think it is something else going wrong. I'm debugging it now.

@rholshausen
Copy link
Contributor

Ok, got it failing correctly now (it was ignoring any error when loading the interaction).

Failures:

1) Failed to load pact - Failed to load pact '/home/ronald/Development/Pact/pact-php/example/matchers/provider/tests/../../pacts/matchersConsumer-matchersProvider.json' - Empty bracket expressions are not allowed in path expression "locales[]" at index 8


There were 1 pact failures

@rholshausen
Copy link
Contributor

Now to fix that issue

@rholshausen
Copy link
Contributor

0.4.13 works for me

@tienvx
Copy link
Contributor Author

tienvx commented Jan 19, 2024

It works for me too. But I got another issue. Probably it's not related, so I will close this issue and create another issue for it.

EDITED: Here is the issue anyway:

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

@tienvx
Copy link
Contributor Author

tienvx commented Jan 19, 2024

Created another issue for it #360

Thank you for fixing this one. Closing.

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
Projects
None yet
Development

No branches or pull requests

2 participants