Skip to content

Validation is broken #500

Closed
Closed

Description

@adgerrits

Describe the Bug
Event.validate() is not functioning correct (tested in the express-ex example)

Steps to Reproduce

  1. let e = HTTP.toEvent({headers: req.headers,body: { "a space": "not allowed", specversion: "1.0", source: "source1", id: "1", type: "test" }
  2. e.validate() //no error

Expected Behavior
An error (just like when an ext.attribute with the name "Acapital" is used).

Additional context
The problem seems to lie in spec.ts because of a broken reference tot the v1-schema. Looks as if it's there since release 5.4.0 when a separate schema-folder was created.

Activity

  1. lance commented on Jun 21, 2022

    @lance
    Member

    The problem seems to lie in spec.ts because of a broken reference tot the v1-schema. Looks as if it's there since release 5.4.0 when a separate schema-folder was created.

    I know it seems that way, but the schema is actually precompiled at build time, so you don't see it in this source repository. You can see where this was changed here: #471 and where it actually happens during the build here:

    "build:schema": "ajv compile -c ./src/schema/formats.js -s src/schema/cloudevent.json --strict-types false -o src/schema/v1.js",

    This seems like a genuine bug in the validation code. Extensions, unfortunately, do not have a formalized JSON spec that we can use to generate a validator (pretty sure about that). You can see in the CloudEvent spec that it does not mention extensions: https://github.com/cloudevents/spec/blob/main/cloudevents/formats/cloudevents.json. Thanks for reporting this.

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

    type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions