Skip to content

Extension Naming Validation Bug #389

@MB1211

Description

@MB1211

This is NOT fixed by #366 but is very similar and is further evidence that this is a valid bug. This issue has nothing to do with the length of the extension name - it needs to address the valid characters that make up the extension name. Currently it only allows lowercase letters (a-z) and numbers (0-9). Extension names need to allow at the very least '-' and '_'

Using JsonFormat, I am getting exceptions thrown for any extension name that is not strictly alphanumeric. I don't think this issue is necessarily specific to JsonFormat though

The spec states "CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') or digits ('0' to '9') from the ASCII character set. Attribute names SHOULD be descriptive and terse and SHOULD NOT exceed 20 characters in length."

But the code BaseCloudEventBuilder to validate the extension name (which references https://github.com/cloudevents/spec/blob/master/spec.md#attribute-naming-convention) seems to be misinterpreting this. It interprets it as MUST ONLY, because the method to validate characters is the following:

private static boolean isValidChar(char c) {
        return (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9');
    }

Unless I'm mistaken, this is not the intent, and a fairly problematic bug. It's not really possible to be descriptive with no way of delimiting words. Elsewhere in the spec, and in the code itself there are mentions of extensions with -'s and '''s so these at the very least should be allowed (ce-, '' ce).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions