siyuan-note/siyuan · error
invalid or duplicate layer ID
Error message
invalid or duplicate layer ID
What it means
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.
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).
Example fix
// before: manifest.json
"layers": [{"id":"bg","type":"image"},{"id":"bg","type":"video"}]
// after
"layers": [{"id":"bg-image","type":"image"},{"id":"bg-video","type":"video"}] Defensive patterns
Strategy: validation
Validate before calling
const ids = (manifest.layers || []).filter(Boolean).map(l => l.id);
const dupes = ids.filter((v, i) => ids.indexOf(v) !== i);
if (dupes.length) throw new Error('duplicate layer ids: ' + dupes.join(','));
if (ids.some(id => !/^[a-z0-9-]+$/.test(id))) throw new Error('invalid layer id'); Type guard
function hasValidLayers(m) { return Array.isArray(m.layers) && m.layers.every(l => l && /^[a-z0-9-]+$/.test(l.id)); } Try / catch
try { loadAppearance(id); } catch (e) { if (/invalid or duplicate layer ID/.test(String(e))) { /* dedupe and rename layer ids in the manifest */ } } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- displayName.default is required
- duplicate AI editor action ID
- image layer cannot declare a poster
- invalid appearance ID
- invalid color [ ]
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/e43fd62720525bb0.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/boot_appearance.go:456
if err = validateOptionalBootAppearanceColor(color); err != nil {
return nil, err
}
}
ret.OfficialUI.TextColor = manifest.OfficialUI.TextColor
ret.OfficialUI.ProgressColor = manifest.OfficialUI.ProgressColor
ret.OfficialUI.TrackColor = manifest.OfficialUI.TrackColor
if manifest.Style != "" {
if _, _, err = validateBootAppearanceResource(pluginDir, appearanceDir, manifest.Style, "style"); err != nil {
return nil, fmt.Errorf("invalid style: %w", err)
}
ret.Style = bootAppearanceAssetURL(pkg.Name, appearanceID, manifest.Style)
}
layerIDs := map[string]bool{}
for _, layer := range manifest.Layers {
if layer == nil || !isValidBootAppearanceID(layer.ID) || layerIDs[layer.ID] {
err = errors.New("invalid or duplicate layer ID")
return nil, err
}
layerIDs[layer.ID] = true
if layer.Type != "image" && layer.Type != "video" {
err = fmt.Errorf("unsupported layer type [%s]", layer.Type)
return nil, err
}
if _, _, err = validateBootAppearanceResource(pluginDir, appearanceDir, layer.Src, layer.Type); err != nil {
return nil, fmt.Errorf("invalid layer source: %w", err)
}
if layer.Type == "video" {
if layer.Poster == "" {
err = errors.New("video poster is required")
return nil, err
}
if _, _, err = validateBootAppearanceResource(pluginDir, appearanceDir, layer.Poster, "image"); err != nil {
return nil, fmt.Errorf("invalid video poster: %w", err)
}View on GitHub (pinned to 9f775e8a12)