pact-go
pact-go copied to clipboard
Invalid Character 'c' in JSON for Provider verification
Software versions
- OS: Mac OSX 10.15.7
- Provider Pact library: pact-go v1.5.1
- Golang Version: go version go1.15.3 darwin/amd64
-
Golang environment: Provide output of
go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jamiec/Library/Caches/go-build"
GOENV="/Users/jamiec/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/jamiec/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/jamiec/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jamiec/Code/app/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bv/kfv_trfd2k1_c9q4gvdk_z9m0000gn/T/go-build247524708=/tmp/go-build -gno-record-gcc-switches -fno-common"
Expected behaviour
Using VSCode test running shortcuts gives in the same results as using the terminal eg. go test
when running a provider pact.VerifyProvider()
test.
Actual behaviour
Because VSCode env has VERBOSE_LOGGING=XXX
the pact-provider-verifier
binary outputs lines like
I, [2020-10-29T17:19:51.954432 #51162] INFO -- request: POST http://localhost:53219/__setup
D, [2020-10-29T17:19:51.954501 #51162] DEBUG -- request: User-Agent: "Faraday v0.17.3"
Content-Type: "application/json"
This results in the verification raising a JSON unmarshalling error: error verifying provider: invalid character 'c' looking for beginning of value
Steps to reproduce
Set VERBOSE_LOGGING=""
in your test env and the unmarshal will error.
Relevent log files
STDOUT:
DEBUG: Setting up provider state 'Some state' for consumer 'XXXXXX' using provider state set up URL http://localhost:53643/__setup
I, [2020-10-29T17:19:02.273199 #51001] INFO -- request: POST http://localhost:53643/__setup
D, [2020-10-29T17:19:02.273243 #51001] DEBUG -- request: User-Agent: "Faraday v0.17.3"
Content-Type: "application/json"
I, [2020-10-29T17:19:02.274652 #51001] INFO -- response: Status 200
D, [2020-10-29T17:19:02.274697 #51001] DEBUG -- response: date: "Thu, 29 Oct 2020 17:19:02 GMT"
content-length: "0"
connection: "close"
{"version":"3.9.2","examples":[{"id":"/usr/local/Cellar/pact-ruby-standalone/1.88.3/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/provider/rspec.rb[1:1:1:1:1:1]","interaction_index":0,"description":"has status code 202","full_description":"Verifying a pact between XXXXXXXX and YYYYYYYY Given Some State A request to ZZZZ with POST /blah returns a response wh...
May be related to https://github.com/pact-foundation/pact-provider-verifier/issues/26
Sorry I thought I'd triaged this. Thanks for the report, we may need to exclude that env var to avoid interference.
A workaround would be to create a workspace setting to exclude that from passing into the go runtime when you run via the IDE.
I'm having this error too. Could you elaborate on how to work around this error?
EDIT: unset VERBOSE_LOGGING
Closing as unplanned, as the 2.x.x release won't have this issue.