diff --git a/.chloggen/mx-psi_limit-for-component-names.yaml b/.chloggen/mx-psi_limit-for-component-names.yaml new file mode 100644 index 00000000000..5b5dcfbb259 --- /dev/null +++ b/.chloggen/mx-psi_limit-for-component-names.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: bug_fix + +# 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: Allow component names of up to 1024 characters in length. + +# One or more tracking issues or pull requests related to the change +issues: [10816] + +# (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: [] diff --git a/component/config.go b/component/config.go index d794a91c28c..8eadee0c1f5 100644 --- a/component/config.go +++ b/component/config.go @@ -166,11 +166,14 @@ var ( ) // nameRegexp is used to validate the name of a component. A name can consist of -// 1 to 63 unicode characters excluding whitespace, control characters, and +// 1 to 1024 unicode characters excluding whitespace, control characters, and // symbols. -var nameRegexp = regexp.MustCompile(`^[^\pZ\pC\pS]{1,63}$`) +var nameRegexp = regexp.MustCompile(`^[^\pZ\pC\pS]+$`) func validateName(nameStr string) error { + if len(nameStr) > 1024 { + return fmt.Errorf("name %q is longer than 1024 characters (%d characters)", nameStr, len(nameStr)) + } if !nameRegexp.MatchString(nameStr) { return fmt.Errorf("invalid character(s) in name %q", nameStr) } diff --git a/component/identifiable_test.go b/component/identifiable_test.go index 7b8dd775350..f4e3595f23d 100644 --- a/component/identifiable_test.go +++ b/component/identifiable_test.go @@ -4,6 +4,7 @@ package component import ( + "strings" "testing" "github.com/stretchr/testify/assert" @@ -43,6 +44,11 @@ func TestUnmarshalText(t *testing.T) { idStr: "valid_type/name-with-dashes", expectedID: ID{typeVal: validType, nameVal: "name-with-dashes"}, }, + // issue 10816 + { + idStr: "valid_type/Linux-Messages-File_01J49HCH3SWFXRVASWFZFRT3J2__processor0__logs", + expectedID: ID{typeVal: validType, nameVal: "Linux-Messages-File_01J49HCH3SWFXRVASWFZFRT3J2__processor0__logs"}, + }, { idStr: "valid_type/1", expectedID: ID{typeVal: validType, nameVal: "1"}, @@ -71,6 +77,10 @@ func TestUnmarshalText(t *testing.T) { idStr: "valid_type/invalid name", expectedErr: true, }, + { + idStr: "valid_type/" + strings.Repeat("a", 1025), + expectedErr: true, + }, } for _, test := range testCases {