Skip to content

Commit 72c7d7f

Browse files
authored
[component] Bump maximum length for component names to 1024 characters (open-telemetry#10818)
#### Description Bumps component name length limit to 1024 characters. #### Link to tracking issue Fixes open-telemetry#10816 #### Testing Added some unit tests.
1 parent 1de1bf1 commit 72c7d7f

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: component
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Allow component names of up to 1024 characters in length.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [10816]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

component/config.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,14 @@ var (
166166
)
167167

168168
// nameRegexp is used to validate the name of a component. A name can consist of
169-
// 1 to 63 unicode characters excluding whitespace, control characters, and
169+
// 1 to 1024 unicode characters excluding whitespace, control characters, and
170170
// symbols.
171-
var nameRegexp = regexp.MustCompile(`^[^\pZ\pC\pS]{1,63}$`)
171+
var nameRegexp = regexp.MustCompile(`^[^\pZ\pC\pS]+$`)
172172

173173
func validateName(nameStr string) error {
174+
if len(nameStr) > 1024 {
175+
return fmt.Errorf("name %q is longer than 1024 characters (%d characters)", nameStr, len(nameStr))
176+
}
174177
if !nameRegexp.MatchString(nameStr) {
175178
return fmt.Errorf("invalid character(s) in name %q", nameStr)
176179
}

component/identifiable_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package component
55

66
import (
7+
"strings"
78
"testing"
89

910
"github.com/stretchr/testify/assert"
@@ -43,6 +44,11 @@ func TestUnmarshalText(t *testing.T) {
4344
idStr: "valid_type/name-with-dashes",
4445
expectedID: ID{typeVal: validType, nameVal: "name-with-dashes"},
4546
},
47+
// issue 10816
48+
{
49+
idStr: "valid_type/Linux-Messages-File_01J49HCH3SWFXRVASWFZFRT3J2__processor0__logs",
50+
expectedID: ID{typeVal: validType, nameVal: "Linux-Messages-File_01J49HCH3SWFXRVASWFZFRT3J2__processor0__logs"},
51+
},
4652
{
4753
idStr: "valid_type/1",
4854
expectedID: ID{typeVal: validType, nameVal: "1"},
@@ -71,6 +77,10 @@ func TestUnmarshalText(t *testing.T) {
7177
idStr: "valid_type/invalid name",
7278
expectedErr: true,
7379
},
80+
{
81+
idStr: "valid_type/" + strings.Repeat("a", 1025),
82+
expectedErr: true,
83+
},
7484
}
7585

7686
for _, test := range testCases {

0 commit comments

Comments
 (0)