From 2fd73aa5f8cb048cbf8caa243c67c57f006bfc1a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 24 Feb 2025 15:32:26 +0100 Subject: [PATCH] config-loader: only apply include transform to known keys Signed-off-by: Patrik Oldsberg --- .changeset/many-wolves-own.md | 5 +++++ packages/config-loader/src/sources/transform/include.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/many-wolves-own.md diff --git a/.changeset/many-wolves-own.md b/.changeset/many-wolves-own.md new file mode 100644 index 0000000000..672af86d62 --- /dev/null +++ b/.changeset/many-wolves-own.md @@ -0,0 +1,5 @@ +--- +'@backstage/config-loader': minor +--- + +The include transforms applied during config loading will now only apply to the known keys `$file`, `$env`, and `$include`. Any other key that begins with a `$` will now be passed through as is. diff --git a/packages/config-loader/src/sources/transform/include.ts b/packages/config-loader/src/sources/transform/include.ts index fb2b22ef46..c476b0434f 100644 --- a/packages/config-loader/src/sources/transform/include.ts +++ b/packages/config-loader/src/sources/transform/include.ts @@ -21,6 +21,8 @@ import { isObject } from './utils'; import { TransformFunc, ReadFileFunc } from './types'; import { SubstitutionFunc } from '../types'; +const INCLUDE_KEYS = ['$file', '$env', '$include']; + // Parsers for each type of included file const includeFileParser: { [ext in string]: (content: string) => Promise; @@ -48,7 +50,9 @@ export function createIncludeTransform( } // Check if there's any key that starts with a '$', in that case we treat // this entire object as an include description. - const [includeKey] = Object.keys(input).filter(key => key.startsWith('$')); + const [includeKey] = Object.keys(input).filter(key => + INCLUDE_KEYS.includes(key), + ); if (includeKey) { if (Object.keys(input).length !== 1) { throw new Error(