Fix yaml parsing in 2.1.1 (#7037)

This commit is contained in:
shamoon
2026-08-21 09:48:25 -07:00
committed by GitHub
parent 728c6fbe18
commit f0bd255adb
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
import * as yaml from "js-yaml";
const EMPTY_DOCUMENT_ERROR = "expected a document, but the input is empty";
const DEFAULT_SCHEMA = yaml.CORE_SCHEMA.withTags(yaml.timestampTag, yaml.mergeTag);
const DEFAULT_SCHEMA = yaml.CORE_SCHEMA.withTags(yaml.timestampTag, yaml.mergeTag, yaml.legacyMapTag);
export function loadYaml(input, options) {
try {
+10
View File
@@ -25,6 +25,16 @@ describe("utils/config/yaml", () => {
});
});
it("preserves v4 handling of non-string keys", () => {
// an unsubstituted {{HOMEPAGE_VAR_*}} parses as a flow mapping key
expect(loadYaml("- Plex:\n widget:\n key: {{HOMEPAGE_VAR_PLEX_KEY}}\n")).toEqual([
{ Plex: { widget: { key: { "[object Object]": null } } } },
]);
expect(loadYaml("- Backups:\n - 2024-01-01:\n href: http://x\n")).toEqual([
{ Backups: [{ [String(new Date("2024-01-01T00:00:00.000Z"))]: { href: "http://x" } }] },
]);
});
it("still rejects invalid YAML", () => {
expect(() => loadYaml("value: [\n")).toThrow();
});