Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message-consumer ignores the metadata given to withMetadata #693

Closed
2 tasks done
dimkin-eu opened this issue Jun 11, 2021 · 7 comments
Closed
2 tasks done

Message-consumer ignores the metadata given to withMetadata #693

dimkin-eu opened this issue Jun 11, 2021 · 7 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@dimkin-eu
Copy link

Checklist

Before making a feature request, I have:

Feature description

in message consumer example only body is verified now, could be nice to do the same also with metadata
To be more specific - dog handler must verify also metadata from spec

Use case

as this info is in the pact and could be verified by providers, could be nice, that it is done also on the js consumer side.

@TimothyJones
Copy link
Contributor

TimothyJones commented Jun 11, 2021 via email

@dimkin-eu
Copy link
Author

@TimothyJones , no worries. dogApiHandler verifies only withContent part, but withMetadata is not (it's not even passed to handler)

@TimothyJones
Copy link
Contributor

@mefellows : Do you know what the metadata field is for? It's not used anywhere in the source as far as I can see (except for where it's set).

@mefellows
Copy link
Member

The metadata is not actually used on the consumer side, or at least, it's not currently exposed to it. It may be used on the provider side, to verify things like message headers.

Classic example would be the queue or topic it's published on.

Pact JS does not currently have the ability to validate message metadata, only Pact JVM does at the present time.

@TimothyJones
Copy link
Contributor

Ah, right. It seems that Pact JS currently allows you to specify the metadata in the consumer, but it's not written to the pact (as far as I can see, it's not even passed beyond the DSL layer).

@TimothyJones TimothyJones added the bug Indicates an unexpected problem or unintended behavior label Jun 16, 2021
@TimothyJones TimothyJones changed the title Create/enhance message consumer example Message-consumer ignores the metadata given to withMetadata Jun 16, 2021
@TimothyJones
Copy link
Contributor

@dimkin-eu What do you think of something like this on the provider side:

  messageProviders: {
    'a request to save an event': providerWithMetadata(
      () => yourUsualProviderHere(),
      { // Arbitrary metadata here
        'content-type': 'application/json',
        messageQueueType: 'AWS-SQS',
      }
    ),
  },

?

@TimothyJones
Copy link
Contributor

This is fixed in 10.0.0-beta.45, and will be released in the next major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants