siyuan-note/siyuan · error
document not found: <documentID>
Error message
document not found: <documentID>
What it means
Returned by resolveMultimodalDocument when treenode.GetBlockTree(strings.TrimSpace(documentID)) returns nil — the ID is not present in the in-memory blocktree.db index. This helper backs ListDocumentImages, PrepareDocumentImage, and GenerateDocumentImage, so all three surface it. The literal documentID (pre-trim) is interpolated into the message.
Source
Thrown at kernel/model/assets.go:474
if err != nil {
return GenerateDocumentImageResult{}, err
}
assetPath, _, err := InsertAssetBytes(bt.RootID, "ai-image"+generated.Extension, generated.Data)
if err != nil {
return GenerateDocumentImageResult{}, markImageExecutionUnknown(fmt.Errorf("save generated image failed: %w", err))
}
return GenerateDocumentImageResult{
Artifact: ImageArtifactRef{
Kind: "image", Path: assetPath, MIMEType: generated.MIMEType, DocumentID: bt.RootID,
},
RevisedPrompt: generated.RevisedPrompt,
}, nil
}
func resolveMultimodalDocument(documentID string) (*treenode.BlockTree, error) {
bt := treenode.GetBlockTree(strings.TrimSpace(documentID))
if bt == nil {
return nil, errors.New("document not found: " + documentID)
}
return bt, nil
}
func validateImageModel(provider *conf.Provider, imageModel *conf.Model) error {
if provider == nil || imageModel == nil {
return errors.New("image model is not configured")
}
if provider.Protocol != "" && provider.Protocol != "openai" {
return fmt.Errorf("unsupported multimodal provider protocol: %s", provider.Protocol)
}
return nil
}
func documentReferencesImage(rootID, assetPath string) bool {
paths, err := DocImageAssets(rootID)
if err != nil {
return falseView on GitHub (pinned to 251596fc0d)
Solutions
- Validate documentID format (it must match ast.IsNodeIDPattern — a 14-20 digit timestamp) before calling.
- Ensure the kernel has finished booting and indexing notebooks before issuing the call.
- If the ID is stale, re-query the doc list / search to get a fresh ID.
Example fix
// before
imgs, err := model.ListDocumentImages(docID) // docID may be stale/garbage
// after — validate the ID shape first
if !ast.IsNodeIDPattern(strings.TrimSpace(docID)) {
return errors.New("invalid document ID")
}
imgs, err := model.ListDocumentImages(docID) Defensive patterns
Strategy: validation
Validate before calling
docID := strings.TrimSpace(documentID)
if !ast.IsNodeIDPattern(docID) {
return errors.New("invalid document ID format")
}
if treenode.GetBlockTree(docID) == nil {
return errors.New("document not found")
} Prevention
- Validate the document ID shape (NodeIDPattern) at the request boundary.
- Wait for kernel indexing to complete before issuing doc-based calls.
- Re-query for fresh IDs when a doc may have been deleted.
When it happens
Trigger: Passing a non-existent, malformed, or whitespace-padded document ID; an ID that was deleted; an ID from a different workspace whose blocktree hasn't been loaded; calling before the kernel indexed the notebooks.
Common situations: Stale client-side cached doc ID after the doc was deleted; copy/paste truncated the ID; the kernel just started and hasn't finished initial indexing; wrong workspace is mounted.
Related errors
- block not found
- parent block not found: %s
- Failed to update agent session permission
- Agent capability name and description are required
- invalid frontend capability ID: %s
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/4614246bf4066f01.
Report an issue: GitHub.