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

Unable find pacts when using pactBrokerUrl with context path #420

Open
4 of 5 tasks
JesusHM opened this issue Feb 28, 2024 · 10 comments
Open
4 of 5 tasks

Unable find pacts when using pactBrokerUrl with context path #420

JesusHM opened this issue Feb 28, 2024 · 10 comments
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer upstream Indicates that an issue relates to an upstream problem (such as in pact-reference)

Comments

@JesusHM
Copy link

JesusHM commented Feb 28, 2024

Software versions

  • OS: Mac OSX 14.3.1
  • Consumer Pact library: Pact JS v12.2.0
  • Provider Pact library: Pact JS v12.2.0
  • Node Version: v18.18.2

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 and have read the section on intermittent test failures
  • 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

On verification phase, when configuring the pactBrokerUrl property witch contain a context path, ( for example https://my.domain.com**/pact**), pact should be able to fetch the corresponding contracts

Actual behaviour

Pact remove the context path from the pactBrokerUrl, trying to get them from the parent (https://my.domain.com/) , and therefore, fail

Steps to reproduce

  1. Create a pact broker with a contextpath, for example https://my.domain.com/pact
  2. Publish a contract in the broker
  3. Configure pactBrokerUrl to the broker with context path
  4. Try to execute the verification

Relevant log files

INFO ThreadId(02) pact_verifier::pact_broker**: Fetching path '/' from pact broker ERROR ThreadId(0") pact_verifier: No pacts found for provider 'test-provider' matching the given consumer version selectors in pact broker 'https://my.domain.com/pact': Link/Resource was not found - No pacts for provider 'test-provider' were found in the pact broker. URL: 'https://my.domain.com/pact'

@JesusHM JesusHM added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Feb 28, 2024
@mefellows
Copy link
Member

Could you please attach the full TRACE level thread as an attachment here (please redact any sensitive info)?

I believe the upstream issue was fixed in #220.

@mefellows mefellows added the awaiting feedback Awaiting Feedback from OP label Feb 29, 2024
@JesusHM
Copy link
Author

JesusHM commented Feb 29, 2024

Attached log file with the complete run
pact_path_error.log

@mefellows
Copy link
Member

2024-02-29T09:21:50.750811Z TRACE ThreadId(02) verify_provider_async:fetch_pacts{source=[BrokerWithDynamicConfiguration { provider_name: "service-provider-ms", broker_url: "https://my.domain.com/pact-broker/", enable_pending: false, include_wip_pacts_since: None, provider_tags: [], provider_branch: Some(""), selectors: [ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: None, deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: Some(true), branch: None, matching_branch: None }, ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: None, deployed_or_released: Some(true), deployed: None, released: None, environment: None, main_branch: None, branch: None, matching_branch: None }, ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: None, deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: None, branch: Some("main"), matching_branch: None }], auth: Some(User("xxxxx", Some("xxxxx"))), links: [] }] consumers=[] provider=ProviderInfo { name: "service-provider-ms", protocol: "http", host: "127.0.0.1", port: Some(52133), path: "/", transports: [ProviderTransport { transport: "http", port: Some(52133), path: Some("/"), scheme: None }] }}:fetch_pact{source=BrokerWithDynamicConfiguration { provider_name: "service-provider-ms", broker_url: "https://my.domain.com/pact-broker/", enable_pending: false, include_wip_pacts_since: None, provider_tags: [], provider_branch: Some(""), selectors: [ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: None, deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: Some(true), branch: None, matching_branch: None }, ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: None, deployed_or_released: Some(true), deployed: None, released: None, environment: None, main_branch: None, branch: None, matching_branch: None }, ConsumerVersionSelector { consumer: None, tag: None, fallback_tag: None, latest: None, deployed_or_released: None, deployed: None, released: None, environment: None, main_branch: None, branch: Some("main"), matching_branch: None }], auth: Some(User("xxxxx", Some("xxxxx"))), links: [] } provider=ProviderInfo { name: "service-provider-ms", protocol: "http", host: "127.0.0.1", port: Some(52133), path: "/", transports: [ProviderTransport { transport: "http", port: Some(52133), path: Some("/"), scheme: None }] }}: h2::proto::streams::streams: drop_stream_ref; stream=Stream { id: StreamId(1), state: State { inner: Closed(EndStream) }, is_counted: false, ref_count: 1, next_pending_send: None, is_pending_send: false, send_flow: FlowControl { window_size: Window(65535), available: Window(0) }, requested_send_capacity: 0, buffered_send_data: 0, send_task: None, pending_send: Deque { indices: None }, next_pending_send_capacity: None, is_pending_send_capacity: false, send_capacity_inc: false, next_open: None, is_pending_open: false, is_pending_push: false, next_pending_accept: None, is_pending_accept: false, recv_flow: FlowControl { window_size: Window(2097152), available: Window(2097152) }, in_flight_recv_data: 0, next_window_update: None, is_pending_window_update: false, reset_at: None, next_reset_expire: None, pending_recv: Deque { indices: None }, is_recv: false, recv_task: None, pending_push_promises: Queue { indices: None, _p: PhantomDatah2::proto::streams::stream::NextAccept }, content_length: Remaining(0) }

This entry looks suspicious, but it's hard to tell as it doesn't look like the request/response is logged. The 404 would suggest it's hit a path that doesn't exist though.

@rholshausen does the attached log indicate a problem in the core? I think it's not in JS at least, as the /pact-broker context path seems to be coming through OK.

@rholshausen
Copy link
Contributor

Can't tell. It seems to have made the request to the Broker to fetch the pb:provider-pacts-for-verification link, and got a 404 Not Found response back. This is to the index that returns all the links.

@mefellows
Copy link
Member

Yeah, I thought so. I was expecting to see the raw HTTP request/response in those logs - were they removed @JesusHM or are they just not present?

@JesusHM can you please issue a call to the root resource e.g.

curl -v -H"Accept: application/hal+json" https://my.domain.com/pact-broker/ (replace the host/path and redact as necessary)

@JesusHM
Copy link
Author

JesusHM commented Mar 5, 2024

I've not removed any line from the log. Curl works fine.

The easier way to reproduce the problem is:

GET / HTTP/1.1
authorization: Basic XXXXXX
accept: application/hal+json, application/json
user-agent: pact_verifier/1.0.6
accept-encoding: gzip, deflate
host: localhots:9090

As you can see, the intial request is done to GET "/" and the path "pact-broker" is lost (as log should show GET /pact-broker HTTP/1.1)

@YOU54F
Copy link
Member

YOU54F commented Apr 2, 2024

If you look at the HAL browser, do the returned links have the path suffix /pact-broker?

The pact broker uses HAL relations, and the client cli's request the index link for the broker and retrieves a set of links to folllow, if this isn't configured to have the suffix, then there will be a 404 as the calling client is redirected to a url that doesn't exist.

See

The full URL (including port, if non-standard for the protocol) at which the application will be made available to users. This is used to create the links in the API.

@jesus-gft-hernandez-db
Copy link

yes, the HAL does return the context path /pact-broker,

The problem is the first request, the one fetching the HAL the one which ignore the context path, trying to get the HAL from / and then, failing

@jesus-gft-hernandez-db
Copy link

Also to mention that java implementation works fine

@mefellows
Copy link
Member

Looks like the issue might be upstream in the pact reference library. I've tested with the latest CLI verifier and the same issue occurs. Moving upstream.

@mefellows mefellows added upstream Indicates that an issue relates to an upstream problem (such as in pact-reference) and removed awaiting feedback Awaiting Feedback from OP labels May 16, 2024
@mefellows mefellows transferred this issue from pact-foundation/pact-js May 16, 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 triage This issue is yet to be triaged by a maintainer upstream Indicates that an issue relates to an upstream problem (such as in pact-reference)
Projects
None yet
Development

No branches or pull requests

5 participants