https://pact.io logo
#pact-broker
Title
# pact-broker
é

Édouard Lopez

05/31/2022, 2:08 PM
Hello, while publishing contracts from a project, 1 contract is published with success while the 5 others trigger a `500`:
Copy code
> Task :pactPublish
PUT JSON request failed with status HTTP/1.1 500 Internal Server Error
Publishing 'ms.customer-order-computation-ms.product-order.json' with tags git-tag-missing, HEAD ... Failed - Request failed with HTTP/1.1 500 Internal Server Error
{"error":{"message":"An error has occurred. The details have been logged with the reference ITHepmbWaB","reference":"ITHepmbWaB"}}
• Did you met this issue already? • Can I access those log from the UI?
b

Beth (pactflow.io/Pact Broker/pact-ruby)

05/31/2022, 10:17 PM
@Édouard Lopez you need to find out where the logs are being shipped to. The person who deployed your broker will have set that up.
The logs go to stdout of the docker container, which will likely be captured and/or forwarded by your docker container management service (eg. kubernetes)
Are these new contracts, or has it just started occurring after an upgrade?
There was an issue that I fixed recently where invalid UTF-8 characters in the body of a request were causing an error to be raised when generating the 400 response because the error message itself contained the UTF-8 character, which then could not be serialized to JSON, causing a 500 error to be returned instead.
é

Édouard Lopez

06/01/2022, 7:41 AM
That's new contracts we try to publish, I updated last week to
2.99.0
I found those log through our datadog:
2022-05-30 153905.691665 E [33:puma srv tp 002 logging.rb:48] PactBroker:Errors:ErrorLogger -- Error reference eCqKAhYxok -- Exception: NoMethodError: undefined method `gsub' for nil:NilClass
b

Beth (pactflow.io/Pact Broker/pact-ruby)

06/01/2022, 9:30 PM
@Édouard Lopez you'll need to provide the full backtrace for me to identify what the problem is.
é

Édouard Lopez

06/13/2022, 1:22 PM
They manage to workaround using the CLI to create the pacticipants, we are investigating
I got more log:
Copy code
2022-06-13 13:58:31.326225 D [34:puma srv tp 004] pact-broker -- (0.000503s) SELECT "name" FROM "pacticipants" ORDER BY "name"
2022-06-13 13:58:31.326814 D [34:puma srv tp 004] pact-broker -- (0.000388s) SELECT "name" FROM "pacticipants" ORDER BY "name"
2022-06-13 13:58:31.327723 E [34:puma srv tp 004 logging.rb:48] PactBroker::Errors::ErrorLogger -- Error reference ueeXehYZSi -- Exception: NoMethodError: undefined method `gsub' for nil:NilClass
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb:30:in `split'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb:26:in `clean'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb:21:in `block in call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb:20:in `select'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb:20:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/find_potential_duplicate_pacticipant_names.rb:14:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/service.rb:27:in `find_potential_duplicate_pacticipants'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/service.rb:17:in `block in messages_for_potential_duplicate_pacticipants'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/service.rb:16:in `each'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/pacticipants/service.rb:16:in `messages_for_potential_duplicate_pacticipants'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/api/resources/pacticipant_resource_methods.rb:9:in `potential_duplicate_pacticipants?'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/api/resources/pact.rb:42:in `is_conflict?'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/decision/flow.rb:500:in `p3'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/decision/fsm.rb:31:in `block (2 levels) in run'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/decision/fsm.rb:51:in `handle_exceptions'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/decision/fsm.rb:31:in `block in run'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/decision/fsm.rb:29:in `loop'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/decision/fsm.rb:29:in `run'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/dispatcher.rb:46:in `block in dispatch'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/as-notifications-1.0.2/lib/as/notifications.rb:161:in `instrument'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/events.rb:75:in `instrument'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/dispatcher.rb:45:in `dispatch'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/webmachine-1.6.0/lib/webmachine/adapters/rack.rb:68:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/cascade.rb:47:in `block in call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/cascade.rb:38:in `each'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/cascade.rb:38:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/database_transaction.rb:46:in `block in call_with_transaction'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/sequel-5.56.0/lib/sequel/database/transactions.rb:258:in `_transaction'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/sequel-5.56.0/lib/sequel/database/transactions.rb:233:in `block in transaction'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/sequel-5.56.0/lib/sequel/connection_pool/threaded.rb:92:in `hold'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/sequel-5.56.0/lib/sequel/database/connecting.rb:269:in `synchronize'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/sequel-5.56.0/lib/sequel/database/transactions.rb:195:in `transaction'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/database_transaction.rb:45:in `call_with_transaction'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/database_transaction.rb:24:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/convert_404_to_hal.rb:10:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/no_auth.rb:9:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:244:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/cascade.rb:47:in `block in call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/cascade.rb:38:in `each'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/cascade.rb:38:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/urlmap.rb:74:in `block in call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `each'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/static.rb:161:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/hal_browser/redirect.rb:20:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/set_base_url.rb:15:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/convert_file_extension_to_accept_header.rb:28:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/static.rb:161:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/static.rb:161:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/add_vary_header.rb:34:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/add_pact_broker_version_header.rb:14:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/reset_thread_data.rb:13:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/invalid_uri_protection.rb:24:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/use_when.rb:30:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-protection-2.2.0/lib/rack/protection/content_security_policy.rb:72:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/rack/pact_broker/use_when.rb:28:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-protection-2.2.0/lib/rack/protection/xss_header.rb:18:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-protection-2.2.0/lib/rack/protection/json_csrf.rb:26:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-protection-2.2.0/lib/rack/protection/base.rb:50:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-protection-2.2.0/lib/rack/protection/frame_options.rb:31:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:244:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/pact_broker-2.99.0/lib/pact_broker/app.rb:91:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/puma-5.6.4/lib/puma/configuration.rb:252:in `call'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/puma-5.6.4/lib/puma/request.rb:77:in `block in handle_request'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/puma-5.6.4/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/puma-5.6.4/lib/puma/request.rb:76:in `handle_request'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/puma-5.6.4/lib/puma/server.rb:441:in `process_client'
/pact_broker/vendor/bundle/ruby/2.7.0/gems/puma-5.6.4/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
2022-06-13 13:58:31.327844 I [34:puma srv tp 004] PactBroker::Errors::ErrorLogger --
b

Beth (pactflow.io/Pact Broker/pact-ruby)

06/13/2022, 10:23 PM
Looks like one of the pacticipant names being used to publish is null.
é

Édouard Lopez

06/14/2022, 7:30 AM
it's weird cause using the pact-cli we can publish :S
b

Beth (pactflow.io/Pact Broker/pact-ruby)

06/15/2022, 12:39 AM
@Édouard Lopez can you see if you can get the debug logs from the failed request, so we can work out what’s missing?
é

Édouard Lopez

06/24/2022, 8:14 AM
Other teams have the same issue when trying to publish new contracts :S
This happens on the Broker version
2.101.0.0
, we have a message that is a bit different
Copy code
> Configure project :
fatal: No annotated tags can describe 'c7c37886f8cc68b75cdfee3c4404b22b7bfd9d37'.
However, there were unannotated tags: try --tags.
> Task :pactPublish FAILED
Publishing 'ms.customer-delivery-ms.carrier.json' with tags git-tag-missing, HEAD ... 
Got an invalid notices value from the Pact Broker: Expected an array, got Null
Failed - Request to path '<http://infra-pact-broker-web.support.manomano.com/contracts/publish>' failed with response 500
{"error":{"message":"An error has occurred. The details have been logged with the reference MngWRRZpRk","reference":"MngWRRZpRk"}}
FAILURE: Build failed with an exception.
* What went wrong:
One or more of the pact files were rejected by the pact broker
Here is the stacktrace from for the
POST
on
/contracts/publish
:
I use a repo with working contract and publication to just change the name of consumer and provider to something that was not in the broker, and it fails. So sound like a Broker regression.
b

Beth (pactflow.io/Pact Broker/pact-ruby)

06/24/2022, 9:07 PM
Thanks, that’s really helpful @Édouard Lopez.
Unfortunately, I still can’t reproduce the error!
I’ve taken your exact body and sent it with a curl, and this is what I get.
Copy code
+ curl -v -XPOST -H 'Content-Type: application/json' -d@/var/folders/9_/0ck5csjn64d78ttbzh9_n_mc0000gp/T/tmp.oEan8Hf1 <http://127.0.0.1:9292/contracts/publish>
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1:9292...
* Connected to 127.0.0.1 (127.0.0.1) port 9292 (#0)
> POST /contracts/publish HTTP/1.1
> Host: 127.0.0.1:9292
> User-Agent: curl/7.77.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 15257
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Vary: Accept
< Content-Type: application/hal+json;charset=utf-8
< Content-Length: 3813
< Date: Fri, 24 Jun 2022 21:06:15 GMT
< Server: Webmachine-Ruby/1.6.0 Rack/1.3
< X-Pact-Broker-Version: 2.101.0
< X-Content-Type-Options: nosniff
< Connection: Keep-Alive
<
* Connection #0 to host 127.0.0.1 left intact
{"logs":[{"level":"debug","message":"Created ms.customer-delivery version unspecified with tags v0.20.2, dx-4628-pact","deprecationWarning":"Replaced by notices"},{"level":"prompt","message":"  Next steps:\n    Configure the version branch to be the value of your repository branch.","deprecationWarning":"Replaced by notices"},{"level":"success","message":"Pact successfully published for ms.customer-delivery version unspecified and provider ms.carrier.","deprecationWarning":"Replaced by notices"},{"level":"debug","message":"  View the published pact at <http://localhost:9292/pacts/provider/ms.carrier/consumer/ms.customer-delivery/version/unspecified>","deprecationWarning":"Replaced by notices"},{"level":"debug","message":"  Events detected: contract_published, contract_content_changed (first time any pact published for this consumer with consumer version tagged v0.20.2, first time any pact published for this consumer with consumer version tagged dx-4628-pact)","deprecationWarning":"Replaced by notices"},{"level":"prompt","message":"  Next steps:","deprecationWarning":"Replaced by notices"},{"level":"prompt","message":"    * Add Pact verification tests to the ms.carrier build. See <https://docs.pact.io/go/provider_verification>","deprecationWarning":"Replaced by notices"},{"level":"prompt","message":"    * Configure separate ms.carrier pact verification build and webhook to trigger it when the pact content changes. See <https://docs.pact.io/go/webhooks>","deprecationWarning":"Replaced by notices"}],"notices":[{"type":"debug","text":"Created ms.customer-delivery version unspecified with tags v0.20.2, dx-4628-pact"},{"type":"prompt","text":"  Next steps:\n    Configure the version branch to be the value of your repository branch."},{"type":"success","text":"Pact successfully published for ms.customer-delivery version unspecified and provider ms.carrier."},{"type":"debug","text":"  View the published pact at <http://localhost:9292/pacts/provider/ms.carrier/consumer/ms.customer-delivery/version/unspecified>"},{"type":"debug","text":"  Events detected: contract_published, contract_content_changed (first time any pact published for this consumer with consumer version tagged v0.20.2, first time any pact published for this consumer with consumer version tagged dx-4628-pact)"},{"type":"prompt","text":"  Next steps:"},{"type":"prompt","text":"    * Add Pact verification tests to the ms.carrier build. See <https://docs.pact.io/go/provider_verification>"},{"type":"prompt","text":"    * Configure separate ms.carrier pact verification build and webhook to trigger it when the pact content changes. See <https://docs.pact.io/go/webhooks>"}],"_embedded":{"pacticipant":{"name":"ms.customer-delivery","_links":{"self":{"href":"<http://localhost:9292/pacticipants/ms.customer-delivery>"}}},"version":{"number":"unspecified","_links":{"self":{"title":"Version","name":"unspecified","href":"<http://localhost:9292/pacticipants/ms.customer-delivery/versions/unspecified>"}}}},"_links":{"pb:pacticipant":{"title":"Pacticipant","name":"ms.customer-delivery","href":"<http://localhost:9292/pacticipants/ms.customer-delivery>"},"pb:pacticipant-version":{"title":"Pacticipant version","name":"unspecified","href":"<http://localhost:9292/pacticipants/ms.customer-delivery/versions/unspecified>"},"pb:pacticipant-version-tags":[{"title":"Tag","name":"v0.20.2","href":"<http://localhost:9292/pacticipants/ms.customer-delivery/versions/unspecified/tags/v0.20.2>"},{"title":"Tag","name":"dx-4628-pact","href":"<http://localhost:9292/pacticipants/ms.customer-delivery/versions/unspecified/tags/dx-4628-pact>"}],"pb:contracts":[{"title":"Pact","name":"Pact between ms.customer-delivery (unspecified) and ms.carrier","href":"<http://localhost:9292/pacts/provider/ms.carrier/consumer/ms.customer-delivery/version/unspecified>"}]}}
Ok, something is not right. The error stack you have shared comes from the resource for publishing pacts using the old endpoint (/pacts/provider/PROVIDER/consumer/CONSUMER/version/VERSION).
pact_broker/api/resources/pact.rb:4
However, the request body you have shared is for the new endpoint at /contracts/publish, and which is in
pact_broker/api/resources/publish_contracts.rb
Can you find me the stack for the error
HxcRTpwUXa
please?
Ah! I think you have a saved pacticipant with an empty name.
There was a bug where if you tried to update a pacticipant in a particular way, it created a duplicate pacticipant with a null name. I’ve recently fixed that.
You’ll need to go into your database and run
delete from pacticipants where name is null
é

Édouard Lopez

06/27/2022, 10:24 AM
I will see to this with one of our SRE. Please be sure to check the related messages https://pact-foundation.slack.com/archives/C9VPNUJR2/p1656323446314029?thread_ts=1656077762.613129&amp;cid=C9VPNUJR2