cloudevents / spec

CloudEvents Specification
https://cloudevents.io
Apache License 2.0
5.1k stars 586 forks source link

Should attribute names be allowed to start with a digit? #1285

Closed duglin closed 5 months ago

duglin commented 6 months ago

Today the spec says:

In order to maximize the likelihood of interoperability and portability across transport protocols and
messaging formats, 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.

Normally digits aren't great as first characters of identifiers.

If we want to restrict it w/o breaking the spec we could say they "SHOULD start with a-z" instead of "MUST"

embano1 commented 6 months ago

Normally digits aren't great as first characters of identifiers

True from personal preference (human perspective) - but is there a technical reason why a machine would care?

If we want to restrict it w/o breaking the spec we could say they "SHOULD start with a-z" instead of "MUST"

Is there any prior art where this has become a problem after the fact?

duglin commented 6 months ago

The scenario that keeps popping in my head is one where someone tries to map CE attributes to programming language variables... and 9x isn't a valid variable name, and often not allowed as a structure property name. Which means people would need some kind of mapping. Possible, but a pain for people who are trying to support things in a generic way.

embano1 commented 6 months ago

Wasn't aware of mapping attributes to variable names (how would that work?). For structures I agree but IMHO extension attributes are supposed to be (parsed as) strings so any (?) map type (with string keys) in a programming language should work?