It seems similar to another similar issue I had a ...
# general
t
It seems similar to another similar issue I had a while back around the escaped slash ending up being
\\\\
every so often when parsed 😕
For now I will try using a raw string literal instead for the regex but possibly an issue on the pact cli side?
m
Is the issue on publish or something else?
Are you using PactFlow or a self-hosted broker? (I ask, because it might be tripping a WAF rule or something)
t
this is on pact publish specifically
We are using self hosted pact broker in GKE using GCP Managed Cert and Ingress etc
Copy code
+ docker run -v /bitrise/src/pacts:/pacts pactfoundation/pact-cli:0.51.0.0 pact-broker publish /pacts --consumer-app-version 6d3721fa3c71f3e431d1af8265b6bff368b5ac2a --branch task/VIS-3411-instrumented-tests-announce-tx-journey-update --broker-base-url <https://pact-broker.tools.ld.payments.dojo.dev> --broker-username [REDACTED] --broker-[REDACTED] '[REDACTED]'
Unable to find image 'pactfoundation/pact-cli:0.51.0.0' locally
0.51.0.0: Pulling from pactfoundation/pact-cli
9621f1afde84: Pulling fs layer
8302e5003f61: Pulling fs layer
9bd515237796: Pulling fs layer
a9c2f95dc8b8: Pulling fs layer
d659e923d195: Pulling fs layer
0496e58000ed: Pulling fs layer
3ae718baa03f: Pulling fs layer
8a6f32654e19: Pulling fs layer
1e4a0858513a: Pulling fs layer
bbf55dfda7e7: Pulling fs layer
d31bd4799644: Pulling fs layer
75e247ce101c: Pulling fs layer
f73e386bc3e7: Pulling fs layer
d659e923d195: Waiting
6ae2a9f86af1: Pulling fs layer
1e4a0858513a: Waiting
0496e58000ed: Waiting
3ae718baa03f: Waiting
bbf55dfda7e7: Waiting
d31bd4799644: Waiting
8a6f32654e19: Waiting
6ae2a9f86af1: Waiting
a9c2f95dc8b8: Waiting
f73e386bc3e7: Waiting
8302e5003f61: Verifying Checksum
8302e5003f61: Download complete
9bd515237796: Verifying Checksum
9bd515237796: Download complete
9621f1afde84: Download complete
d659e923d195: Verifying Checksum
d659e923d195: Download complete
0496e58000ed: Verifying Checksum
0496e58000ed: Download complete
3ae718baa03f: Verifying Checksum
3ae718baa03f: Download complete
8a6f32654e19: Verifying Checksum
8a6f32654e19: Download complete
9621f1afde84: Pull complete
1e4a0858513a: Verifying Checksum
1e4a0858513a: Download complete
a9c2f95dc8b8: Verifying Checksum
a9c2f95dc8b8: Download complete
8302e5003f61: Pull complete
d31bd4799644: Verifying Checksum
d31bd4799644: Download complete
75e247ce101c: Verifying Checksum
75e247ce101c: Download complete
6ae2a9f86af1: Verifying Checksum
6ae2a9f86af1: Download complete
9bd515237796: Pull complete
bbf55dfda7e7: Verifying Checksum
bbf55dfda7e7: Download complete
f73e386bc3e7: Verifying Checksum
f73e386bc3e7: Download complete
a9c2f95dc8b8: Pull complete
d659e923d195: Pull complete
0496e58000ed: Pull complete
3ae718baa03f: Pull complete
8a6f32654e19: Pull complete
1e4a0858513a: Pull complete
bbf55dfda7e7: Pull complete
d31bd4799644: Pull complete
75e247ce101c: Pull complete
f73e386bc3e7: Pull complete
6ae2a9f86af1: Pull complete
Digest: sha256:b7d9facf2566cbe23c404fa2baaf3b7bb7c417788ad9f83d765fa72cea1a9754
Status: Downloaded newer image for pactfoundation/pact-cli:0.51.0.0
/usr/lib/ruby/gems/3.0.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse': 859: unexpected token at 'nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsImV4cCI6MTY0NjMxNjU5NywiaWF0IjoxNjQ2MzEyOTk2LCJzdWIiOiJhZy1zdGFnaW5nLW1vYmlsZUBhcHBzcG90LmdzZXJ2aWNlYWNjb3VudC5jb20iLCJ1aWQiOiI0MTEwMDAzNyJ9.MLpkCQI5bOSmdJuneQdwChEYvXhkaigd4ouPOn5f2Rw" (JSON::ParserError)
        },
        "headers": {
          "Content-Type": "application/json; charset=UTF-8"
        },
        "matchingRules": {
          "$.body.token": {
            "match": "regex",
            "regex": "^[A-Za-z0-9-_=]+\\\\.[A-Za-z0-9-_=]+\\\\.?[A-Za-z0-9-_.+/=]*$"
          }
        },
        "status": 200
      }
    }
  ],
  "metadata": {
    "pact-jvm": {
      "version": "4.3.5"
    },
    "pactSpecification": {
      "version": "2.0.0"
    }
  },
  "provider": {
    "name": "OtacProviderService"
  }
}
'
	from /usr/lib/ruby/gems/3.0.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/pact_file.rb:28:in `pact_hash'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/pact_file.rb:20:in `consumer_name'
	from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect'
	from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:145:in `consumer_names'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:60:in `publish_pacts'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:33:in `call'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:15:in `call'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/pact_commands.rb:66:in `publish_pacts'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/pact_commands.rb:29:in `publish'
	from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/custom_thor.rb:23:in `start'
	from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/bin/pact-broker:10:in `<top (required)>'
	from /usr/bin/pact-broker:25:in `load'
	from /usr/bin/pact-broker:25:in `<main>'
Copy code
apiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: Ingress
metadata:
  name: {{ include "pactbroker.fullname" . }}
  namespace: {{ .Values.namespace }}
  annotations:
    <http://external-dns.alpha.kubernetes.io/hostname|external-dns.alpha.kubernetes.io/hostname>: {{ .Values.cloudEndpoints.hostName | quote }}
    <http://kubernetes.io/ingress.allow-http|kubernetes.io/ingress.allow-http>: "true"  # allow-http and use frontendConfig to redirect to https
    <http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>: "gce"
    <http://networking.gke.io/managed-certificates|networking.gke.io/managed-certificates>: {{ include "pactbroker.fullname" . }}
    <http://networking.gke.io/v1beta1.FrontendConfig|networking.gke.io/v1beta1.FrontendConfig>: "frontendconfig-ssl-modern-tls12"
spec:
  rules:
    - host: {{ .Values.cloudEndpoints.hostName | quote }}
      http:
        paths:
          - path: /*
            pathType: ImplementationSpecific
            backend:
              service:
                name: pact-broker-service
                port:
                  number: 80
---
apiVersion: <http://networking.gke.io/v1beta1|networking.gke.io/v1beta1>
kind: FrontendConfig
metadata:
  name: frontend-config-redirect-to-https
spec:
  redirectToHttps:
    enabled: true
    responseCodeName: "MOVED_PERMANENTLY_DEFAULT"
---
apiVersion: <http://networking.gke.io/v1beta1|networking.gke.io/v1beta1>
kind: FrontendConfig
metadata:
  name: frontendconfig-ssl-modern-tls12
spec:
  sslPolicy: ssl-policy-modern-tls12
  redirectToHttps:
    enabled: true
    responseCodeName: "MOVED_PERMANENTLY_DEFAULT"
m
Thanks! Have you been able to confirm if the file is indeed invalid JSON? That would help us get to the bottom of it - sounds like perhaps an invalid JSON document is being serialised by your consumer client library (as I think you hinted at)
t
I mean it passes 90% of the time in CI and this issue pops up occasionally, the contracts haven't changed between them
and when it works I correctly see the output that it was preverified etc
m
🤔 so strange!
t
I recently merged a potential fix by using raw string literals in kotlin instead of relying on
\\
for escaped slashes, so will monitor CI over the next week or so and see if the issue still happens or not
👍 1