{"record":{"id":"891ecc532615952b","repo":"siyuan-note/siyuan","slug":"unsupported-box-document-metadata-spec-d","errorCode":null,"errorMessage":"unsupported box document metadata spec [%d]","messagePattern":"unsupported box document metadata spec \\[(.+?)\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/box_doc.go","lineNumber":74,"sourceCode":"\t}\n\treturn \"/\" + boxID + \".sy\"\n}\n\nfunc readBoxDocID(boxID string) (ret string, err error) {\n\tdata, err := filelock.ReadFile(boxDocMetaPath(boxID))\n\tif err != nil {\n\t\tif errors.Is(err, os.ErrNotExist) {\n\t\t\terr = nil\n\t\t}\n\t\treturn\n\t}\n\n\tmeta := &boxDocMeta{}\n\tif err = gulu.JSON.UnmarshalJSON(data, meta); err != nil {\n\t\treturn \"\", fmt.Errorf(\"unmarshal box document metadata failed: %w\", err)\n\t}\n\tif boxDocMetaSpec != meta.Spec {\n\t\treturn \"\", fmt.Errorf(\"unsupported box document metadata spec [%d]\", meta.Spec)\n\t}\n\tif !ast.IsNodeIDPattern(meta.BoxDocID) {\n\t\treturn \"\", fmt.Errorf(\"invalid box document ID [%s]\", meta.BoxDocID)\n\t}\n\tif boxID != meta.BoxDocID {\n\t\treturn \"\", fmt.Errorf(\"box document ID [%s] does not match box ID [%s]\", meta.BoxDocID, boxID)\n\t}\n\treturn boxID, nil\n}\n\nfunc writeBoxDocID(boxID string) error {\n\tmeta := &boxDocMeta{Spec: boxDocMetaSpec, BoxDocID: boxID}\n\tdata, err := gulu.JSON.MarshalIndentJSON(meta, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marshal box document metadata failed: %w\", err)\n\t}\n\treturn filelock.WriteFile(boxDocMetaPath(boxID), data)\n}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/box_doc.go#L56-L92","documentation":"boxDoc.json carries a spec version; this error fires when the parsed spec does not equal the supported boxDocMetaSpec (currently 1). The metadata file was written by a newer (or older) incompatible format, and the kernel refuses to interpret an unknown spec rather than guessing. This is a forward/backward compatibility guard for the notebook document-node feature.","triggerScenarios":"readBoxDocID (via ensureBoxDoc0 or TestBoxDocMetadataMatchesBoxID) reads a .siyuan/boxDoc.json whose spec field is 0, 2, or any value != 1 — typically a file written by a future SiYuan version.","commonSituations":"Opening a workspace last used by a newer SiYuan build that bumped the spec; hand-crafted boxDoc.json with a missing (spec=0) or wrong spec value; mixed-version sync between devices.","solutions":["Upgrade SiYuan to the version that wrote the boxDoc.json (matching its spec)","Recreate the file with spec 1: delete .siyuan/boxDoc.json so ensureBoxDoc0 rewrites it in the current format","Check for mixed-version clients syncing the same workspace and align all clients to the same SiYuan version"],"exampleFix":"// before\n{\"spec\": 2, \"boxDocID\": \"...\"}\n// after\n{\"spec\": 1, \"boxDocID\": \"20240101120000-abcdefg\"}","handlingStrategy":"try-catch","validationCode":"var probe struct{ Spec int `json:\"spec\"` }\nif json.Unmarshal(data, &probe) == nil && probe.Spec != 1 {\n    // unsupported spec: upgrade SiYuan or delete boxDoc.json to regenerate\n}","typeGuard":null,"tryCatchPattern":"if _, err := readBoxDocID(boxID); err != nil && strings.Contains(err.Error(), \"unsupported box document metadata spec\") {\n    // migrate: upgrade app version or regenerate the metadata file\n}","preventionTips":["Run the same SiYuan version on all devices syncing a workspace","Upgrade before opening workspaces created by newer builds","Never hand-set the spec field"],"tags":["versioning","compatibility","notebook","metadata"],"backgroundTag":"unsupported-enum-value","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"}