From 41f6c77e739641b1fd0d469f31f494b3ca7dd764 Mon Sep 17 00:00:00 2001 From: Tolyan Korniltsev Date: Tue, 30 Jun 2026 11:49:01 +0700 Subject: [PATCH 1/2] Validate label characters in config and migrate to mise.toml Reject appName and tag keys/values containing Prometheus label syntax characters, and replace .tool-versions with mise.toml including corepack for Yarn on Node 26. --- .tool-versions | 2 - mise.toml | 6 +++ src/utils/check-pyroscope-config.ts | 71 +++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) delete mode 100644 .tool-versions create mode 100644 mise.toml diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index 19cfa50d..00000000 --- a/.tool-versions +++ /dev/null @@ -1,2 +0,0 @@ -nodejs 26.2.0 - diff --git a/mise.toml b/mise.toml new file mode 100644 index 00000000..a773903c --- /dev/null +++ b/mise.toml @@ -0,0 +1,6 @@ +[tools] +node = "26.2.0" + +[tools."npm:corepack"] +version = "0.35.0" +postinstall = "corepack enable" diff --git a/src/utils/check-pyroscope-config.ts b/src/utils/check-pyroscope-config.ts index 7945f5c2..bd2c9424 100644 --- a/src/utils/check-pyroscope-config.ts +++ b/src/utils/check-pyroscope-config.ts @@ -4,6 +4,10 @@ import { PyroscopeWallConfig, } from '../pyroscope-config.js'; +const INVALID_LABEL_CHARACTERS = ['{', '}', ',', '='] as const; +const INVALID_LABEL_CHARACTERS_MESSAGE = + "'{', '}', ',', or '=' characters"; + export function checkPyroscopeConfig( config: unknown ): asserts config is PyroscopeConfig { @@ -15,8 +19,12 @@ export function checkPyroscopeConfig( if (!hasValidApplicationName(config)) { errors.push('Expecting a config with string appName'); + } else { + validateApplicationName(config, errors); } + validateTags(config, errors); + if (!hasValidAuthToken(config)) { errors.push('Expecting a config with string auth token'); } @@ -51,6 +59,69 @@ function hasValidApplicationName( ); } +function validateApplicationName( + config: Record, + errors: string[] +): void { + const appName: string | undefined = (config as Partial) + .appName; + + if (appName === undefined) { + return; + } + + if (hasInvalidLabelCharacters(appName)) { + errors.push( + `appName must not contain ${INVALID_LABEL_CHARACTERS_MESSAGE}` + ); + } +} + +function validateTags( + config: Record, + errors: string[] +): void { + const tags: unknown = (config as Partial).tags; + + if (tags === undefined) { + return; + } + + if (!isObject(tags)) { + errors.push('Expecting a config with object tags'); + return; + } + + for (const [tagKey, tagValue] of Object.entries(tags)) { + if (hasInvalidLabelCharacters(tagKey)) { + errors.push( + `tag key "${tagKey}" must not contain ${INVALID_LABEL_CHARACTERS_MESSAGE}` + ); + } + + if (typeof tagValue === 'string' && hasInvalidLabelCharacters(tagValue)) { + errors.push( + `tag value for "${tagKey}" must not contain ${INVALID_LABEL_CHARACTERS_MESSAGE}` + ); + } else if ( + typeof tagValue !== 'number' && + typeof tagValue !== 'string' + ) { + errors.push(`tag value for "${tagKey}" must be a string or number`); + } + } +} + +function hasInvalidLabelCharacters(value: string): boolean { + for (const character of INVALID_LABEL_CHARACTERS) { + if (value.includes(character)) { + return true; + } + } + + return false; +} + function hasValidAuthToken(config: Record): boolean { return ( (config as Partial).authToken === undefined || From ed5d22a595c781d6bd49208a51896f6e95a374d9 Mon Sep 17 00:00:00 2001 From: Tolyan Korniltsev Date: Tue, 30 Jun 2026 11:52:20 +0700 Subject: [PATCH 2/2] Bump Node to 26.4.0 in mise.toml and release workflow Align local and CI Node pins with the latest 26.x release. --- .github/workflows/release-please.yml | 2 +- mise.toml | 2 +- src/utils/check-pyroscope-config.ts | 12 +++--------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 4bb7a021..8c9c6072 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -49,7 +49,7 @@ jobs: - name: Setup .npmrc file to publish to npm uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: - node-version: '26.2.0' + node-version: '26.4.0' registry-url: 'https://registry.npmjs.org' package-manager-cache: false - name: Enable corepack diff --git a/mise.toml b/mise.toml index a773903c..8ab0b32b 100644 --- a/mise.toml +++ b/mise.toml @@ -1,5 +1,5 @@ [tools] -node = "26.2.0" +node = "26.4.0" [tools."npm:corepack"] version = "0.35.0" diff --git a/src/utils/check-pyroscope-config.ts b/src/utils/check-pyroscope-config.ts index bd2c9424..9e689c2e 100644 --- a/src/utils/check-pyroscope-config.ts +++ b/src/utils/check-pyroscope-config.ts @@ -5,8 +5,7 @@ import { } from '../pyroscope-config.js'; const INVALID_LABEL_CHARACTERS = ['{', '}', ',', '='] as const; -const INVALID_LABEL_CHARACTERS_MESSAGE = - "'{', '}', ',', or '=' characters"; +const INVALID_LABEL_CHARACTERS_MESSAGE = "'{', '}', ',', or '=' characters"; export function checkPyroscopeConfig( config: unknown @@ -71,9 +70,7 @@ function validateApplicationName( } if (hasInvalidLabelCharacters(appName)) { - errors.push( - `appName must not contain ${INVALID_LABEL_CHARACTERS_MESSAGE}` - ); + errors.push(`appName must not contain ${INVALID_LABEL_CHARACTERS_MESSAGE}`); } } @@ -103,10 +100,7 @@ function validateTags( errors.push( `tag value for "${tagKey}" must not contain ${INVALID_LABEL_CHARACTERS_MESSAGE}` ); - } else if ( - typeof tagValue !== 'number' && - typeof tagValue !== 'string' - ) { + } else if (typeof tagValue !== 'number' && typeof tagValue !== 'string') { errors.push(`tag value for "${tagKey}" must be a string or number`); } }