Hi, I've set PublishVerificationResult switch to t...
# pact-net
p
Hi, I've set PublishVerificationResult switch to true in my code. Also set up the version But in pipeline it fails with below error After adding these switches publish is failing with below error `publish_verification_results': Error returned from verification results publication 401 (Pact:ProviderVerificationResults:PublicationError) Am I missing any other setting?
t
401 means that you’re not authenticated. So you’ll need to check / provide your basic auth username and password for the broker (or access token if you’re using pactflow)
p
That's already in place while connecting to PactBroker
var pactUriOptions = new PactUriOptions() .SetBasicAuthentication(config["PACT_BROKER_USERNAME"], config["PACT_BROKER_USERNAME"]); pactVerifier .PactBroker(config["PACT_BROKER_BASEURI"], pactUriOptions);
m
The error is pretty clear, so I'd be inclined to assume your configuration is wrong (e.g. CONFIG is not populated or the values are incorrect). Enabling debug logging might help understand further
p
Actually @Matt (pactflow.io / pact-js / pact-go) apparently it seems that issue only. But for us we able to fetch the pact n verify it. Problem only while publishing. Do we need any other settings as well. Other teams from our org using same creds for publishing. from nodejs / java projects. And it works fine. From .Net we are receiving this error. So wanted to know if any other setting also required
I've set Verbose = true. my consumer is written using Pact 4x version and Provider is written using 3x, could that be a probable issue with publishing pact verification results? @Matt (pactflow.io / pact-js / pact-go) @Timothy Jones
t
I would expect that the problem is that the token is not correct or not set
☝️ 1
the pact version should not make a difference
1
Specifically:
Copy code
var pactUriOptions = new PactUriOptions()
        .SetBasicAuthentication(config["PACT_BROKER_USERNAME"], config["PACT_BROKER_USERNAME"]);
^ This has PACT_BROKER_USERNAME for both the username and the password.
☝️ 1
p
ok so we need to pass token instead of creds...Thanks a lot. Will try this
@Timothy Jones @Matt (pactflow.io / pact-js / pact-go) I verified the other applications with in our org, we are using only the user id and password...n it's working fine for tehn w/i any issues. const publishOpts: VerifierOptions = { pactBrokerUsername: process.env.PACT_BROKER_USERNAME, pactBrokerPassword: process.env.PACT_BROKER_PASSWORD, providerVersion: process.env.GIT_COMMIT || '', providerVersionTags: [process.env.GIT_BRANCH ?? ''], publishVerificationResult: true, pactBrokerUrl: process.env.PACT_BROKER_URL, consumerVersionSelectors: [ { // branch: process.env.GIT_BRANCH, // TODO: proper branch matching latest: true, }, ], }; const opts: VerifierOptions = { pactBrokerUrl: 'https://pact-broker.com', consumerVersionSelectors: [ { latest: true, }, ], ...(process.env.PACT_BROKER_URL && publishOpts),
m
ok so we need to pass token instead of creds...Thanks a lot. Will try this
the point Tim was making is that you are passing the username when you should be passing the password
the token is if you’re using PactFlow or if you’ve added some custom auth. If you have a self-hosted / OSS broker, username/password is what you need
p
I got it...It was very sad mistake from my end. Thanks a lot
😆 1
m
haha it happens 😉