From 9a16824fdbb32f6c1c90234e291487fca7b9c79f Mon Sep 17 00:00:00 2001 From: Juan Pablo Garcia Ripa Date: Thu, 25 Sep 2025 20:34:04 +0200 Subject: [PATCH] fix: error messages on tests Signed-off-by: Juan Pablo Garcia Ripa --- .../backend-app-api/src/wiring/BackendInitializer.test.ts | 7 ++++--- packages/config-loader/src/sources/EnvConfigSource.ts | 5 +---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/backend-app-api/src/wiring/BackendInitializer.test.ts b/packages/backend-app-api/src/wiring/BackendInitializer.test.ts index 7be989a0ea..79f0f36540 100644 --- a/packages/backend-app-api/src/wiring/BackendInitializer.test.ts +++ b/packages/backend-app-api/src/wiring/BackendInitializer.test.ts @@ -27,7 +27,8 @@ import { import { BackendInitializer } from './BackendInitializer'; import { mockServices } from '@backstage/backend-test-utils'; import { BackendStartupError } from './BackendStartupError'; -import { CONFIG_KEY_PART_PATTERN } from '@backstage/config'; + +const ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/i; const baseFactories = [ mockServices.rootLifecycle.factory(), @@ -1026,7 +1027,7 @@ describe('BackendInitializer', () => { }), ); await expect(init.start()).rejects.toThrow( - `Invalid pluginId 'test:invalid&id', must match the pattern ${CONFIG_KEY_PART_PATTERN} (letters, digits, dashes, and underscores only, starting with a letter)`, + `Invalid pluginId 'test:invalid&id', must match the pattern ${ID_PATTERN} (letters, digits, and dashes only, starting with a letter)`, ); }); @@ -1056,7 +1057,7 @@ describe('BackendInitializer', () => { }), ); await expect(init.start()).rejects.toThrow( - `Invalid moduleId 'invalid:module&id' for plugin 'test', must match the pattern ${CONFIG_KEY_PART_PATTERN} (letters, digits, dashes, and underscores only, starting with a letter)`, + `Invalid moduleId 'invalid:module&id' for plugin 'test', must match the pattern ${ID_PATTERN} (letters, digits, and dashes only, starting with a letter)`, ); }); diff --git a/packages/config-loader/src/sources/EnvConfigSource.ts b/packages/config-loader/src/sources/EnvConfigSource.ts index 988110b370..ffb615754f 100644 --- a/packages/config-loader/src/sources/EnvConfigSource.ts +++ b/packages/config-loader/src/sources/EnvConfigSource.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { AppConfig } from '@backstage/config'; +import { AppConfig, CONFIG_KEY_PART_PATTERN } from '@backstage/config'; import { assertError } from '@backstage/errors'; import { JsonObject } from '@backstage/types'; import { AsyncConfigSourceGenerator, ConfigSource } from './types'; @@ -84,9 +84,6 @@ export class EnvConfigSource implements ConfigSource { const ENV_PREFIX = 'APP_CONFIG_'; -// Update the same pattern in config package if this is changed -const CONFIG_KEY_PART_PATTERN = /^[a-z][a-z0-9]*(?:[-_:][a-z0-9]+)*$/i; - /** * Read runtime configuration from the environment. *