Skip to content

Unexpected content in AsynchronousMessage #516

@phooijenga

Description

@phooijenga

We have a series of tests that boil down to the following:

mockProvider.
	AddAsynchronousMessage().
	Given("something happens").
	ExpectsToReceive("a notification").
	WithContent("application/json", eventJSON).
	ConsumedBy(handleWrapper).
	Verify(t)

We have had some of them intermittently failing. The consumer function (or Pact, if we use AsType) is unable to parse the AsynchronousMessage.Contents, usually failing with an error similar to invalid character '\x01' after top-level value.

In one particularly interesting case, we found that there was a complete SQL statement included in the message contents.

I think the root cause of the problem lies in Message.WithContents, which seems to assume that a byte slice can be safely cast to a *C.char. As far as I know, Go makes no guarantees that a slice is NUL terminated.

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