Skip to content

CloudEvent extensions should be restricted to types allowed in spec #229

Closed

Description

@lance

Currently an extension can have any value - e.g. it could be an object. However, the spec limits what value types an extension can have. See https://github.com/cloudevents/spec/blob/master/spec.md#type-system

Activity

  1. added
    type/bugSomething isn't working
    spec/1.0Issues related to the CE specification
    on Jun 20, 2020
  2. added
    version/3.xIssues related to the 3.0 release of this library
    on Jul 8, 2020
  3. lholmquist commented on Jul 8, 2020

    @lholmquist
    Contributor

    Since the spec doesn't allow an Object, should we be throwing an error if someone passes in this:

    new CloudEvent({
    ...
    ...
    extension1: { key: value }
    })
    

    Or is this ok since it will get converted to a JSON before transmission. basically, should this test pass or fail: https://github.com/cloudevents/sdk-javascript/blob/master/test/integration/spec_1_tests.ts#L99

  4. lance commented on Jul 13, 2020

    @lance
    MemberAuthor

    That test should probably fail. We can't assume that the receiver will know that the value needs to be converted to an object. Since strings are valid value types, the user should use JSON.stringify before setting the extension.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec/1.0Issues related to the CE specificationtype/bugSomething isn't workingversion/3.xIssues related to the 3.0 release of this library

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions