From 8f6e64f5fef829283310f9d47bb711cb78dcb58b Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Tue, 6 Aug 2024 18:43:30 +0200 Subject: [PATCH 1/2] [component] Double length for component names --- .../mx-psi_limit-for-component-names.yaml | 25 +++++++++++++++++++ component/config.go | 4 +-- component/identifiable_test.go | 10 ++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .chloggen/mx-psi_limit-for-component-names.yaml 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..59967504d7f --- /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 127 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..94f56313bb0 100644 --- a/component/config.go +++ b/component/config.go @@ -166,9 +166,9 @@ 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 127 unicode characters excluding whitespace, control characters, and // symbols. -var nameRegexp = regexp.MustCompile(`^[^\pZ\pC\pS]{1,63}$`) +var nameRegexp = regexp.MustCompile(`^[^\pZ\pC\pS]{1,127}$`) func validateName(nameStr string) error { if !nameRegexp.MatchString(nameStr) { diff --git a/component/identifiable_test.go b/component/identifiable_test.go index 7b8dd775350..656e26fd4af 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", 128), + expectedErr: true, + }, } for _, test := range testCases { From 40a8eccf22a390784b6ab01d26ce99cb6dc47dc7 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Wed, 7 Aug 2024 11:49:26 +0200 Subject: [PATCH 2/2] Bump to 1024 characters and have a clearer error message --- .chloggen/mx-psi_limit-for-component-names.yaml | 2 +- component/config.go | 7 +++++-- component/identifiable_test.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.chloggen/mx-psi_limit-for-component-names.yaml b/.chloggen/mx-psi_limit-for-component-names.yaml index 59967504d7f..5b5dcfbb259 100644 --- a/.chloggen/mx-psi_limit-for-component-names.yaml +++ b/.chloggen/mx-psi_limit-for-component-names.yaml @@ -7,7 +7,7 @@ change_type: bug_fix 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 127 characters in length. +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] diff --git a/component/config.go b/component/config.go index 94f56313bb0..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 127 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,127}$`) +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 656e26fd4af..f4e3595f23d 100644 --- a/component/identifiable_test.go +++ b/component/identifiable_test.go @@ -78,7 +78,7 @@ func TestUnmarshalText(t *testing.T) { expectedErr: true, }, { - idStr: "valid_type/" + strings.Repeat("a", 128), + idStr: "valid_type/" + strings.Repeat("a", 1025), expectedErr: true, }, }