Skip to content

Allowing space characters in the Namespace #177

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export enum Constants {
MAX_DIMENSION_VALUE_LENGTH = 1024,
MAX_METRIC_NAME_LENGTH = 1024,
MAX_NAMESPACE_LENGTH = 256,
VALID_NAMESPACE_REGEX = '^[a-zA-Z0-9._#:/-]+$',
VALID_NAMESPACE_REGEX = '^(?=.*\S)[a-zA-Z0-9 ._#:/-]+$',
VALID_DIMENSION_REGEX = '^[\x00-\x7F]+$',
MAX_TIMESTAMP_PAST_AGE = 1209600000, // 2 weeks
MAX_TIMESTAMP_FUTURE_AGE = 7200000, // 2 hours
Expand Down
4 changes: 2 additions & 2 deletions src/logger/__tests__/MetricsContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ test('put metric with same key and different resolution in single flush throws e
}).toThrow(InvalidMetricError);
});

test.each([[''], [' '], ['a'.repeat((Constants.MAX_NAMESPACE_LENGTH as number) + 1)], ['àẁş/ćļốṹḓⱳầƭḉⱨ'], ['namespace ']])(
test.each([[''], [' '], ['a'.repeat((Constants.MAX_NAMESPACE_LENGTH as number) + 1)], ['àẁş/ćļốṹḓⱳầƭḉⱨ']])(
'setNamespace with invalid namespace: %s throws error',
(namespace) => {
// arrange
Expand All @@ -430,7 +430,7 @@ test.each([[''], [' '], ['a'.repeat((Constants.MAX_NAMESPACE_LENGTH as number) +
test('setNamespace with valid namespace does not throw error', () => {
// arrange
const context = MetricsContext.empty();
const namespace = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/#:';
const namespace = '1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz .-_/#:';

// act
expect(() => {
Expand Down