Hello Pact Team, I really don't know where I can a...
# general
p
Hello Pact Team, I really don't know where I can ask for the right channel? However, I try to run workshops which JS and Golang. I've found the same problem with Ruby. So I am not sure how to fix it. Golang: https://github.com/pact-foundation/pact-workshop-go
Copy code
<class:CGIHandler>': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
JS: https://github.com/pact-foundation/pact-workshop-js Anyone please help me to fix this 🙂
m
hmm I’ve seen this before but I don’t think we ever fully chased it down
I think it might be an environment variable
any chance you could please take a dump of your environment, redact anything important, and share?
Do you also happen to have a ruby installation at all?
p
Pact need to install Ruby, right?
I think Pact can run without require Ruby installation
☝️ 1
However, I try to find a software list to install to make sure I missed something to install. So I just see only workshop and it make me understand to have at all.
m
You don’t need to install Ruby, no
I was interested if you did, because that could explain the problem
I’m expecting some environment variable or configuration that Ruby is detecting that’s not utf-8 (ascii-8bit).
What’s your OS/arch?
What is your default language and encoding?
p
Linux
👍 1
Not sure for how to check
encoding UTF-8
🤔 1
I ty with JS workshop first it get the same errors
m
strange
p
Maybe it is just a warning message. I see the next error about this
I still confusing about MOCK_SERVER and PACT_BROKER Is that the same thing?
m
no
mock server is used locally to mock the provider API
the pact broker is used to share contracts and collaborate
I suspect that’s because the ruby process didn’t start correctly so the golang tests are not able to talk to the mock
p
Mock server that start from pact lib, right?
👍 1
Actually, I will start using pact with PHP but the document is not hard to understand. I will try to do the workshop first.
@Matt (pactflow.io / pact-js / pact-go) Could you please let me know if you have any update?
👍 1
y
Can you
Copy code
echo $LANG
on your machine?
I get
en_GB.UTF-8
b
I get
en_AU.UTF-8
, and I've had weird problems in WSL with unsupported locales. Definitely good to check 👌
p
I get
en_US.UTF-8
@Yousaf Nabi (pactflow.io)
The problem related to a terminal? I using ZSH not Bash.
For more detail
Copy code
go test -tags=integration -count=1 <http://github.com/pact-foundation/pact-workshop-go/consumer/client|github.com/pact-foundation/pact-workshop-go/consumer/client> -run 'TestClientPact'
2022/02/24 12:46:45 [INFO] checking pact-mock-service within range >= 3.5.0, < 4.0.0
2022/02/24 12:46:45 [INFO] checking pact-provider-verifier within range >= 1.31.0, < 2.0.0
2022/02/24 12:46:45 [INFO] checking pact-broker within range >= 1.22.3
2022/02/24 12:46:46 [ERROR] service: /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb:21:in `<class:CGIHandler>': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb:19:in `<module:HTTPServlet>'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb:17:in `<module:WEBrick>'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb:16:in `<top (required)>'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet.rb:13:in `require'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet.rb:13:in `<top (required)>'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:16:in `require'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:16:in `<top (required)>'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick.rb:225:in `require'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick.rb:225:in `<top (required)>'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/ssl.rb:8:in `require'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/ssl.rb:8:in `<top (required)>'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/https.rb:11:in `require'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/https.rb:11:in `<top (required)>'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.9.0/lib/pact/mock_service/cli.rb:173:in `require'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.9.0/lib/pact/mock_service/cli.rb:173:in `require_common_dependencies'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.9.0/lib/pact/mock_service/cli.rb:30:in `service'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
2022/02/24 12:46:46 [ERROR] service: 	from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/app/pact-mock-service.rb:15:in `<main>'
2022/02/24 12:46:56 [ERROR] Expected server to start < 10s. Timed out waiting for Mock Server to start on port 41519 - are you sure it's running?
--- FAIL: TestClientPact_GetUser (0.00s)
    --- FAIL: TestClientPact_GetUser/the_user_exists (0.00s)
        client_pact_test.go:73: Error on Verify: Post "<http://localhost:41519/interactions>": dial tcp 127.0.0.1:41519: connect: connection refused
FAIL
Post "<http://localhost:41519/pact>": dial tcp 127.0.0.1:41519: connect: connection refused
FAIL	<http://github.com/pact-foundation/pact-workshop-go/consumer/client|github.com/pact-foundation/pact-workshop-go/consumer/client>	11.194s
FAIL
m
No, I use ZSH it’s not the terminal
can you please run
file -ib /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb
?
I’m wondering if somehow, the files themselves are encoded differently
I think you’re on linux, I believe that’s the right flag to get the encoding
p
I get this
text/x-ruby; charset=us-ascii
👍 1
m
I noticed your file path had extended characters in it. Seems unlikely to be the cause, but if you move it to a dir like
/tmp/foo
do you still have the same issue?
p
@Matt (pactflow.io / pact-js / pact-go) Wow. It works 🙂 Thanks so much
m
oh really!!
p
Yeah. It is complicated 🙂. However, I walk through step 11 of the workshop. I try to publish the pact file to https://test.pact.dius.com.au https://test.pact.dius.com.au/pacts/provider/GoUserService2022/consumer/GoAdminService2022/latest I got failed when I run the command
make provider
Copy code
FAIL: TestPactProvider/has_a_matching_body (0.00s)
        pact.go:629: Verifying a pact between GoAdminService and GoUserService Given User sally exists A request to login with user 'sally' with GET /user/10 returns a response which has a matching body
        pact.go:635: Verifying a pact between GoAdminService and GoUserService Given User sally exists A request to login with user 'sally' with GET /user/10 returns a response which has a matching body
            Actual: null
            
            Diff
            --------------------------------------
            Key: - is expected 
                 + is actual 
            Matching keys and values are not shown
            
            -{
            -  "firstName": "Sally",
            -  "id": 10,
            -  "lastName": "McSmiley Face😀😍",
            -  "type": "admin",
            -  "username": "sally"
            -}
            
            
            Description of differences
            --------------------------------------
            * Expected a Hash (like {"firstName"=>"Sally", "id"=>10, "lastName"=>"McSmiley Face😀😍", "type"=>"admin", "username"=>"sally"}) but got nil at $
I already tested with the local pact file. It works. @Matt (pactflow.io / pact-js / pact-go) Do you have any ideas?
In the log file not attach Authorization in header
Copy code
# Logfile created on 2022-02-24 19:20:00 +0700 by logger.rb/47272
I, [2022-02-24T19:20:02.367233 #78258]  INFO -- : Running example 'Verifying a pact between GoAdminService and GoUserService Given User sally exists A request to login with user 'sally' with GET /user/10 returns a response which has status code 200'
I, [2022-02-24T19:20:02.374053 #78258]  INFO -- : Sending GET request to path: "/user/10" with headers: {"X_PACT_PROVIDER_STATES"=>[{"name"=>"User sally exists"}]}, see debug logs for body
D, [2022-02-24T19:20:02.374120 #78258] DEBUG -- : body :
I, [2022-02-24T19:20:02.392009 #78258]  INFO -- : Received response with status: 401, headers: {"Content-Length"=>"0", "Content-Type"=>"application/json; charset=utf-8", "Date"=>"Thu, 24 Feb 2022 12:20:02 GMT", "X-Api-Correlation-Id"=>"8c2aa5ba-ea1e-4a39-8dfd-20a333d6f387"}, see debug logs for body
D, [2022-02-24T19:20:02.392090 #78258] DEBUG -- : body:
m
It looked like what was published has a different name to what you're verifying (missing 2022cin the application names)
So you're probably verifying a different contract
p
@Matt (pactflow.io / pact-js / pact-go) Oh that's true. I see code to set provider name not using
os.Getenv
Now It works. Thanks so much.
👍 1