{"record":{"id":"e43fd62720525bb0","repo":"siyuan-note/siyuan","slug":"invalid-or-duplicate-layer-id","errorCode":null,"errorMessage":"invalid or duplicate layer ID","messagePattern":"invalid or duplicate layer ID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/boot_appearance.go","lineNumber":456,"sourceCode":"\t\tif err = validateOptionalBootAppearanceColor(color); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tret.OfficialUI.TextColor = manifest.OfficialUI.TextColor\n\tret.OfficialUI.ProgressColor = manifest.OfficialUI.ProgressColor\n\tret.OfficialUI.TrackColor = manifest.OfficialUI.TrackColor\n\n\tif manifest.Style != \"\" {\n\t\tif _, _, err = validateBootAppearanceResource(pluginDir, appearanceDir, manifest.Style, \"style\"); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid style: %w\", err)\n\t\t}\n\t\tret.Style = bootAppearanceAssetURL(pkg.Name, appearanceID, manifest.Style)\n\t}\n\n\tlayerIDs := map[string]bool{}\n\tfor _, layer := range manifest.Layers {\n\t\tif layer == nil || !isValidBootAppearanceID(layer.ID) || layerIDs[layer.ID] {\n\t\t\terr = errors.New(\"invalid or duplicate layer ID\")\n\t\t\treturn nil, err\n\t\t}\n\t\tlayerIDs[layer.ID] = true\n\t\tif layer.Type != \"image\" && layer.Type != \"video\" {\n\t\t\terr = fmt.Errorf(\"unsupported layer type [%s]\", layer.Type)\n\t\t\treturn nil, err\n\t\t}\n\t\tif _, _, err = validateBootAppearanceResource(pluginDir, appearanceDir, layer.Src, layer.Type); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid layer source: %w\", err)\n\t\t}\n\t\tif layer.Type == \"video\" {\n\t\t\tif layer.Poster == \"\" {\n\t\t\t\terr = errors.New(\"video poster is required\")\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif _, _, err = validateBootAppearanceResource(pluginDir, appearanceDir, layer.Poster, \"image\"); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid video poster: %w\", err)\n\t\t\t}","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/boot_appearance.go#L438-L474","documentation":"Each layer in the manifest must have an ID that is non-nil, passes isValidBootAppearanceID (identifier format rules), and is unique across the layers array. This error is thrown when the ID is missing/malformed or when two layers share the same ID. Unique valid IDs are required for DOM element identification and per-layer configuration.","triggerScenarios":"GetBootAppearances/getBootAppearanceByID iterates manifest.Layers and encounters a null layer object, a layer with an empty or character-invalid ID, or an ID already seen in a previous iteration of the same manifest.","commonSituations":"Copy-pasting a layer entry in manifest.json and forgetting to change its id; generating layers programmatically with duplicate ids; leaving a trailing null entry in the JSON array; using ids with illegal characters (spaces, slashes, uppercase where disallowed).","solutions":["Give every layer a unique, valid id in manifest.json (rename duplicates, e.g. logo-1, logo-2).","Remove null entries from the layers array.","Run the manifest through a JSON validator that flags duplicate array-member ids before publishing.","Match the identifier rules enforced by isValidBootAppearanceID (e.g. alphanumeric plus dash)."],"exampleFix":"// before: manifest.json\n\"layers\": [{\"id\":\"bg\",\"type\":\"image\"},{\"id\":\"bg\",\"type\":\"video\"}]\n// after\n\"layers\": [{\"id\":\"bg-image\",\"type\":\"image\"},{\"id\":\"bg-video\",\"type\":\"video\"}]","handlingStrategy":"validation","validationCode":"const ids = (manifest.layers || []).filter(Boolean).map(l => l.id);\nconst dupes = ids.filter((v, i) => ids.indexOf(v) !== i);\nif (dupes.length) throw new Error('duplicate layer ids: ' + dupes.join(','));\nif (ids.some(id => !/^[a-z0-9-]+$/.test(id))) throw new Error('invalid layer id');","typeGuard":"function hasValidLayers(m) { return Array.isArray(m.layers) && m.layers.every(l => l && /^[a-z0-9-]+$/.test(l.id)); }","tryCatchPattern":"try { loadAppearance(id); } catch (e) { if (/invalid or duplicate layer ID/.test(String(e))) { /* dedupe and rename layer ids in the manifest */ } }","preventionTips":["Copy-paste check: rename ids immediately after duplicating a layer","Enforce an id naming convention (lowercase alnum + dash)","Add a CI lint that rejects duplicate array ids"],"tags":["boot-appearance","layers","duplicate-id","validation"],"backgroundTag":"invalid-identifier-format","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}