Skip to content

Provider Verification - parse header error coming from pact-ffi #447

@hborham

Description

@hborham

Software versions

  • OS: e.g. linux (al2023)
  • Consumer Pact library: e.g. Pact-js 11.0.2
  • Provider Pact library: e.g. Pact go v2.0.3
  • Golang Version: 1.21
  • Golang environment: Provide output of go env

Expected behaviour

Able to verify the pact header and value.

Actual behaviour

Fails to verify the pact

Request Failed - Invalid header name: 'Failed to parse header value: redacted-encoded-jwt-token

Enabled PACT_LOG_LEVEL=TRACE and this additional output seems relevant

2024-02-08T16:08:33.563649Z ERROR ThreadId(04) pact_ffi::mock_server::handles: Failed to parse the value: expected value at line 1 column 1
2024-02-08T16:08:33.563710Z ERROR ThreadId(04) pact_ffi::mock_server::handles: Failed to parse the value: expected value at line 1 column 1

Steps to reproduce

First noticed in v2.0.3 and pinned our build to v2.0.2

[Container] 2024/02/08 14:00:23.228131 Running command go install github.com/pact-foundation/pact-go/v2@latest
go: downloading github.com/pact-foundation/pact-go/v2 v2.0.3
...truncate
[Container] 2024/02/08 14:00:47.625763 Running command pact-go -l DEBUG install
2024/02/08 14:00:47 [INFO] package libpact_ffi not found
2024/02/08 14:00:47 [INFO] downloading library from https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v0.4.15/libpact_ffi-linux-x86_64.so.gz to /usr/local/lib/libpact_ffi.so&{}
2024/02/08 14:00:48 [DEBUG] obtaining hash for file /usr/local/lib/libpact_ffi.so
2024/02/08 14:00:48 [DEBUG] error reading file /root/.pact/pact-go.yml error:  open /root/.pact/pact-go.yml: no such file or directory
2024/02/08 14:00:48 [DEBUG] writing config {map[libpact_ffi:{libpact_ffi 0.4.15 f6f4064cad0423a21423122287344c0c}]}
2024/02/08 14:00:48 [DEBUG] writing yaml config to file libraries:
  libpact_ffi:
    libname: libpact_ffi
    version: 0.4.15
    hash: f6f4064cad0423a21423122287344c0c
2024/02/08 14:00:48 [INFO] package libpact_ffi found
2024/02/08 14:00:48 [INFO] checking version 0.4.15 of libpact_ffi against semver constraint >= 0.4.0, < 1.0.0
2024/02/08 14:00:48 [DEBUG] 0.4.15 satisfies constraints 0.4.15 >= 0.4.0, < 1.0.0
2024/02/08 14:00:48 [INFO] package libpact_ffi is correctly installed
2024/02/08 14:00:48 [DEBUG] skip checking ffi version() call because FFI not loaded. This is expected when running the 'pact-go' command.

My guess is using a jwt inside the pact below will recreate the error. Alternatively a testcase on the suspected code in ffi library might also easily recreate it.

Pact

{
  "consumer": {
    "name": "BarClient"
  },
  "interactions": [{
      "_id": "redacted",
      "description": "a request to /GetFoo",
      "providerStates": [{
          "name": "An external auth with",
          "params": {
            "authorization": "redacted-encoded-jwt-token",
            "tenant_id": "pact-tenant"
          }
        }, {
          "name": "A default foo",
          "params": {
            "foo_id": "generated",
          }
        }],
      "request": {
        "body": {
        },
        "generators": {
          "header": {
            "$.authorization[0]": {
              "expression": "authorization",
              "type": "ProviderState"
            }
          }
        },
        "headers": {
          "Content-Type": "application/json",
          "authorization": "redacted-encoded-jwt-token"
        },
        "matchingRules": {
          "body": {
            "$": {
              "combine": "AND",
              "matchers": [{
                  "match": "type"
                }]
            }
          },
          "header": {
            "$.authorization[0]": {
              "combine": "AND",
              "matchers": [{
                  "match": "type"
                }]
            }
          }
        },
        "method": "POST",
        "path": "/GetFoo"
      },
      "response": {
        "body": {
          "addressLine1": "123 Wolseley Road",
        },
        "headers": {
          "content-type": "application/json"
        },
        "matchingRules": {
          "body": {
            "$": {
              "combine": "AND",
              "matchers": [{
                  "match": "type"
                }]
            }
          },
          "header": {
          }
        },
        "status": 200
      }
    }],
  "metadata": {
    "pact-js": {
      "version": "11.0.2"
    },
    "pactRust": {
      "ffi": "0.4.0",
      "models": "1.0.4"
    },
    "pactSpecification": {
      "version": "3.0.0"
    }
  },
  "provider": {
    "name": "FooService"
  },
  "createdAt": "2024-07-25T15:26:48+00:00"
}

Relevent log files

conversation from pact-go slack
Please ensure you set logging to DEBUG and attach any relevant log files here (or link from a gist).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions