pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.09k stars 480 forks source link

Request to provider failed with an exception: "/" is not allowed in an identifier in path expression #1556

Closed topsycreed closed 2 years ago

topsycreed commented 2 years ago

Hey!

Steps to reproduce: Sent a get request to endpoint: Method:GET Path:/shipping/v1 Headers: { "Accept": "application/json", "site": "US", "Content-Type": "application/json" } That returning response body with '/' symbols, for example: { "data": [ { "relationships": { "user/shippingAddress": { "data": { "id": "123", "type": "user/shipping-address" } } } } ] }

Actual: At Pact you will see exception: Request to provider failed with an exception: "/" is not allowed in an identifier in path expression "$.data[0].relationships.user/shippingAddress.data.id" at index 28 (au.com.dius.pact.core.model.InvalidPathExpression)

Expected: Test should be passed successfully, since it's already implemented on service end to return such response and consumers expected that.

rholshausen commented 2 years ago

I am not able to replicate this issue with Pact-JVM. See example tests: Consumer and Provider

I did notice that the pact file generated from that consumer test (see pact) has the slash escaped $.data[*].relationships['user/shippingAddress'].data.id, while the error you provided has $.data[0].relationships.user/shippingAddress.data.id which is not valid.

How have you generated the Pact file that was used in your test?

topsycreed commented 2 years ago

Hey @rholshausen thanks for your support! We were able to fix the issue from Consumer side as you mentioned.