siyuan-note/siyuan · error
snapshot file ID is required
Error message
snapshot file ID is required
What it means
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.
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.
Example fix
// before
fetchPost("/api/history/loadDocVersion", { "fileID": "" })
// after
fetchPost("/api/history/loadDocVersion", { "fileID": "20240101150000-def0123-0000000000abcdef" }) Defensive patterns
Strategy: validation
Validate before calling
// JS: require a non-empty snapshot file ID before the request
if (!fileID) throw new Error("snapshot fileID is required");
return fetchPost("/api/history/loadDocVersion", { fileID }); Type guard
function hasFileID(v) { return typeof v === "string" && v.length > 0; } Try / catch
catch (e) { if (e.message === "snapshot file ID is required") { reloadHistoryListAndGetFileID(); } else { throw e; } } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- attribute view snapshot context is ambiguous
- Conf.Language(26)
- snapshot version is not a document
- assetPath is required for analyze
- attribute view history context is ambiguous
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/38b3503d815727aa.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/history_diff.go:399
large: 1024*1024 <= len(data),
boxID: boxID,
history: historyRoot,
}, nil
}
return &loadedDocVersion{
tree: tree,
title: tree.Root.IALAttr("title"),
rootID: tree.Root.ID,
raw: data,
large: 1024*1024 <= len(data),
boxID: boxID,
history: historyRoot,
}, nil
}
func loadSnapshotDocVersion(fileID string) (ret *loadedDocVersion, err error) {
if "" == fileID {
return nil, errors.New("snapshot file ID is required")
}
if 1 > len(Conf.Repo.Key) {
return nil, errors.New(Conf.Language(26))
}
repo, err := newRepository()
if err != nil {
return nil, err
}
file, err := repo.GetFile(fileID)
if err != nil {
return nil, err
}
if !strings.HasSuffix(strings.ToLower(file.Path), ".sy") {
return nil, errors.New("snapshot version is not a document")
}
repoPath := strings.TrimPrefix(file.Path, "/")
pathParts := strings.SplitN(repoPath, "/", 2)
data, err := repo.OpenFile(file)View on GitHub (pinned to 9f775e8a12)