Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[component] Bump maximum length for component names to 1024 characters #10818

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/mx-psi_limit-for-component-names.yaml
Original file line number Diff line number Diff line change
@@ -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: []
7 changes: 5 additions & 2 deletions component/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 10 additions & 0 deletions component/identifiable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package component

import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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 {
Expand Down
Loading