config-loader: only apply include transform to known keys

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-02-24 15:32:26 +01:00
parent 770981908a
commit 2fd73aa5f8
2 changed files with 10 additions and 1 deletions
+5
View File
@@ -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.
@@ -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<JsonObject>;
@@ -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(