diff --git a/.chloggen/component-id-length-limit.yaml b/.chloggen/component-id-length-limit.yaml new file mode 100644 index 00000000000..360c927bb19 --- /dev/null +++ b/.chloggen/component-id-length-limit.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: component + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Restricts maximum length for `component.Type` to 63 characters. + +# One or more tracking issues or pull requests related to the change +issues: [9872] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: ['api'] diff --git a/cmd/mdatagen/validate.go b/cmd/mdatagen/validate.go index 5871adca83d..60ba46f098d 100644 --- a/cmd/mdatagen/validate.go +++ b/cmd/mdatagen/validate.go @@ -35,7 +35,7 @@ func (md *metadata) Validate() error { // can only contain ASCII alphanumeric characters and '_'. // We allow '/' for subcomponents. // This must be kept in sync with the regex in component/config.go. -var typeRegexp = regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]*$`) +var typeRegexp = regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]{0,62}$`) func (md *metadata) validateType() error { if md.Type == "" { diff --git a/component/config.go b/component/config.go index d86df1801bd..49cc7f5219f 100644 --- a/component/config.go +++ b/component/config.go @@ -128,7 +128,7 @@ func (t Type) MarshalText() ([]byte, error) { // A type must start with an ASCII alphabetic character and // can only contain ASCII alphanumeric characters and '_'. // This must be kept in sync with the regex in cmd/mdatagen/validate.go. -var typeRegexp = regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]*$`) +var typeRegexp = regexp.MustCompile(`^[a-zA-Z][0-9a-zA-Z_]{0,62}$`) // NewType creates a type. It returns an error if the type is invalid. // A type must diff --git a/component/config_test.go b/component/config_test.go index f1c3c65b395..caed4dc20ab 100644 --- a/component/config_test.go +++ b/component/config_test.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "reflect" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -397,6 +398,7 @@ func TestNewType(t *testing.T) { {name: "zipkin_encoding"}, {name: "zookeeper"}, {name: "zpages"}, + {name: strings.Repeat("a", 63)}, {name: "", shouldErr: true}, {name: "contains spaces", shouldErr: true}, @@ -405,6 +407,7 @@ func TestNewType(t *testing.T) { {name: "contains/slash", shouldErr: true}, {name: "contains:colon", shouldErr: true}, {name: "contains#hash", shouldErr: true}, + {name: strings.Repeat("a", 64), shouldErr: true}, } for _, tt := range tests {