You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
In compatibility-kit/javascript/features/minimal/minimal.feature.ndjson - modify "seconds":0 to "seconds":"0"
Run cat compatibility-kit/javascript/features/minimal/minimal.feature.ndjson | cucumber-json-formatter
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:
Describe the bug
The
cucumber-json-formatter
executable cannot handle messages with seconds as strings:The
messages
library changed in 16.0.0 to usenumber
instead ofstring
for theseconds
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 aseconds
field is not anumber
, but it should be able to consume the older format too.To Reproduce
Steps to reproduce the behavior:
compatibility-kit/javascript/features/minimal/minimal.feature.ndjson
- modify"seconds":0
to"seconds":"0"
cat compatibility-kit/javascript/features/minimal/minimal.feature.ndjson | cucumber-json-formatter
Expected behavior
It should handle
seconds
as bothnumber
(new schema) andstring
(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.The text was updated successfully, but these errors were encountered: