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

Cannot deserialize messages generated with pre-v16 og the messages library #7

Open
aslakhellesoy opened this issue Oct 18, 2021 · 0 comments

Comments

@aslakhellesoy
Copy link
Contributor

aslakhellesoy commented Oct 18, 2021

Describe the bug

The cucumber-json-formatter executable cannot handle messages with seconds as strings:

{"testRunStarted":{"timestamp":{"seconds":"1634557709","nanos":260000000}}}

The messages library changed in 16.0.0 to use number instead of string for the seconds field.

There are Cucumber users out there that use a Cucumber version that depends on pre-v15 versions of messages.

The latest version of cucumber-json-formatter dies with an error if a seconds field is not a number, but it should be able to consume the older format too.

To Reproduce
Steps to reproduce the behavior:

  1. In compatibility-kit/javascript/features/minimal/minimal.feature.ndjson - modify "seconds":0 to "seconds":"0"
  2. Run cat compatibility-kit/javascript/features/minimal/minimal.feature.ndjson | cucumber-json-formatter
  3. See an error:
ERROR: json: cannot unmarshal string into Go struct field Duration.testStepFinished.testStepResult.duration.seconds of type int64

Expected behavior

It should handle seconds as both number (new schema) and string (old schema).

Analysis

The problem is actually in the messages library, where we unmarshal a JSON string into an object:

https://github.com/cucumber/common/blob/475e714b56c0ab1a0f6887dd18aef527b3b4e53a/messages/go/messages.go#L354

This should ideally be fixed in all the messages implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant