{"record":{"id":"38b3503d815727aa","repo":"siyuan-note/siyuan","slug":"snapshot-file-id-is-required","errorCode":null,"errorMessage":"snapshot file ID is required","messagePattern":"snapshot file ID is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/history_diff.go","lineNumber":399,"sourceCode":"\t\t\tlarge:    1024*1024 <= len(data),\n\t\t\tboxID:    boxID,\n\t\t\thistory:  historyRoot,\n\t\t}, nil\n\t}\n\treturn &loadedDocVersion{\n\t\ttree:    tree,\n\t\ttitle:   tree.Root.IALAttr(\"title\"),\n\t\trootID:  tree.Root.ID,\n\t\traw:     data,\n\t\tlarge:   1024*1024 <= len(data),\n\t\tboxID:   boxID,\n\t\thistory: historyRoot,\n\t}, nil\n}\n\nfunc loadSnapshotDocVersion(fileID string) (ret *loadedDocVersion, err error) {\n\tif \"\" == fileID {\n\t\treturn nil, errors.New(\"snapshot file ID is required\")\n\t}\n\tif 1 > len(Conf.Repo.Key) {\n\t\treturn nil, errors.New(Conf.Language(26))\n\t}\n\trepo, err := newRepository()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfile, err := repo.GetFile(fileID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !strings.HasSuffix(strings.ToLower(file.Path), \".sy\") {\n\t\treturn nil, errors.New(\"snapshot version is not a document\")\n\t}\n\trepoPath := strings.TrimPrefix(file.Path, \"/\")\n\tpathParts := strings.SplitN(repoPath, \"/\", 2)\n\tdata, err := repo.OpenFile(file)","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/history_diff.go#L381-L417","documentation":"loadSnapshotDocVersion loads a document version directly from a repo (snapshot) file identified by its file ID. An empty fileID cannot address any snapshot object, so the loader fails fast with this message before touching the repository key or opening the repo.","triggerScenarios":"Calling loadDocVersion with an empty snapshot file ID — typically an API request where the fileID parameter was omitted or an empty string was passed instead of a valid repo file ID.","commonSituations":"Frontend/plugin passed an undefined/null file ID (e.g. a history entry without its file reference); string coercion turned a missing parameter into \"\"; clipboard/URL parameter lost when sharing a snapshot link.","solutions":["Supply the snapshot file ID from the repo listing / history API (the value used by repo.GetFile).","Check the API caller: ensure the parameter that carries fileID is populated before issuing the request.","Re-open the history/snapshot list and pick the entry again; stale UI state may hold an emptied ID.","If IDs come from a script, add a non-empty check before calling the endpoint."],"exampleFix":"// before\nfetchPost(\"/api/history/loadDocVersion\", { \"fileID\": \"\" })\n// after\nfetchPost(\"/api/history/loadDocVersion\", { \"fileID\": \"20240101150000-def0123-0000000000abcdef\" })","handlingStrategy":"validation","validationCode":"// JS: require a non-empty snapshot file ID before the request\nif (!fileID) throw new Error(\"snapshot fileID is required\");\nreturn fetchPost(\"/api/history/loadDocVersion\", { fileID });","typeGuard":"function hasFileID(v) { return typeof v === \"string\" && v.length > 0; }","tryCatchPattern":"catch (e) { if (e.message === \"snapshot file ID is required\") { reloadHistoryListAndGetFileID(); } else { throw e; } }","preventionTips":["Always source file IDs from the snapshot/repo listing response","Add non-empty checks on parameters before API calls in plugins/scripts","Refresh stale UI history entries that may hold emptied IDs"],"tags":["snapshot","missing-argument","repo"],"backgroundTag":"missing-required-argument","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"}