Skip to content
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
6 changes: 5 additions & 1 deletion ui/server/services/pilotdeckConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,5 +601,9 @@ export function rawYamlToMaskedString(rawYaml) {
}

export function parseConfigYaml(raw) {
return normalizePilotDeckConfig(parseYaml(raw) || {});
const parsed = parseYaml(raw);
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
throw new Error('raw YAML must parse to an object');
}
return normalizePilotDeckConfig(parsed);
}
10 changes: 10 additions & 0 deletions ui/server/services/pilotdeckConfig.raw-yaml.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { describe, expect, it } from 'vitest';
import { parseConfigYaml } from './pilotdeckConfig.js';

describe('parseConfigYaml', () => {
it('rejects raw YAML whose root is not an object', () => {
expect(() => parseConfigYaml('[]')).toThrow('raw YAML must parse to an object');
expect(() => parseConfigYaml('null')).toThrow('raw YAML must parse to an object');
expect(() => parseConfigYaml('plain')).toThrow('raw YAML must parse to an object');
});
});