Skip to content

header method in V4 PactBuilder splits up values #1852

@huehnerlady

Description

@huehnerlady

Hi,
I am currently trying to move to V4 pacts.

Currently I have this pact, which works

@Pact(consumer = CONSUMER, provider = PROVIDER)
RequestResponsePact provider(PactDslWithProvider builder) {
  return builder
      .uponReceiving("get")
      .method("GET")
      .headers("accept", "application/json, application/*+json")
      .path("/test")
      .willRespondWith()
      .status(200)
      .toPact()
}

I migrated it to look like this:

@Pact(consumer = CONSUMER, provider = PROVIDER)
V4Pact provider(PactBuilder builder) {
  return builder
      .expectsToReceiveHttpInteraction("get") { httpBuilder ->
        httpBuilder
            .withRequest { httpRequestBuilder ->
              httpRequestBuilder
                  .path("/test")
                  .method("GET")
                  .headers("accept", "application/json, application/*+json")
            }
            .willRespondWith { httpResponseBuilder ->
              httpResponseBuilder.status(200)
            }
      }
      .toPact()
}

but now I get this error message from Pact:

2025-01-16 11:41:50,475 [HTTP-Dispatcher] ERROR  a.c.d.p.c.BaseMockServer$Companion - PartialRequestMatch: get:
    Expected header 'accept' to have value 'application/json' but was 'application/json, application/*+json'
    Expected header 'accept' to have value 'application/*+json' but was ''

I am very confused as the signature of the method headers I am using shows it as a value:String. I also tried the header method, but I still get the same error.

After asking in Slack what I can do I was asked to raise it as a potential bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions