Skip to content

Possible Serialization bug? #125

@No9

Description

@No9

Hi All
Testing the tide websocket implementation using the example message from
https://github.com/cloudevents/spec/blob/master/json-format.md#32-examples

{
    "specversion" : "1.0",
    "type" : "com.example.someevent",
    "source" : "/mycontext",
    "id" : "A234-1234-1234",
    "time" : "2018-04-05T17:31:00Z",
    "comexampleextension1" : "value",
    "comexampleothervalue" : 5,
    "unsetextension": null,
    "datacontenttype" : "text/xml",
    "data" : "<much wow=\"xml\"/>"
}

Specifically this line 205e16a#diff-97633925b0ac8233888bd3bdc2313999cd86c04f1e7e56a62a8cb1e8d58ba5eaR50

let v: Event = serde_json::from_str(&message).unwrap(); 

fails with

thread 'async-std/runtime' panicked at 'called `Result::unwrap()` on an 
`Err` value: Error("data did not match any variant of untagged enum ExtensionValue", 
line: 0, column: 0)', src/main.rs:50:71

If I remove the property set to null "unsetextension": null, the message works as expected.

{
    "specversion" : "1.0",
    "type" : "com.example.someevent",
    "source" : "/mycontext",
    "id" : "A234-1234-1234",
    "time" : "2018-04-05T17:31:00Z",
    "comexampleextension1" : "value",
    "comexampleothervalue" : 5,
    "datacontenttype" : "text/xml",
    "data" : "<much wow=\"xml\"/>"
}

According to the docs null should be treated as unset or omitted
https://github.com/cloudevents/spec/blob/70823088e52b393b4251abd1ab03b6cfa233d427/json-format.md#22-type-system-mapping.

Do you have any preferences for which it should be?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions