Skip to content

CloudEvent Constructor Validation Error Too Generic #364

@grant

Description

@grant

Describe the Bug

Hi, I'm trying to debug an error from a different user. They're using this SDK.

Their code is like this:

const respondEvent = new CloudEvent({
    type: 'dev.mink.apply.samples.divide',
    source: 'https://github.com/mattmoor/mink-apply-sample/divide',
    time: new Date(),
    dataContentType: 'application/json',
    data: { foo: 'bar' }
  });

However, running this produces the following output:

invalid extension name%                                                                                                                                                         

I think this output could be improved. I don't really know what is wrong and don't know if the user is really trying to create an extension.

  • Ideally, the error would state the field name and exactly what is wrong with the key or value.
  • Ideally, there's be no error (unless there's something really wrong with the data passed in, but it looks fine).

Workaround:

const respondEvent = new CloudEvent({
    type: 'dev.mink.apply.samples.divide',
    source: 'https://github.com/mattmoor/mink-apply-sample/divide',
    time: new Date(),
    dataContentType: 'application/json',
    data: { foo: 'bar' }
  }, false);

Steps to Reproduce

curl -X POST \
-H 'Content-Type: application/json' \
-H 'ce-type: foo' \
-H 'ce-specversion: 1.0' \
-H 'ce-source: blah' \
-H 'ce-id: 1234' \
-d '{"a": 3, "b": 4}' localhost:8080
invalid extension name%              

Thanks!

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