{"record":{"id":"dc9b0e048aba4a8d","repo":"siyuan-note/siyuan","slug":"list-document-images-failed-w","errorCode":null,"errorMessage":"list document images failed: %w","messagePattern":"list document images failed: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/assets.go","lineNumber":437,"sourceCode":"\treturn errors.As(err, &target)\n}\n\nfunc markImageExecutionUnknown(err error) error {\n\tif err == nil || IsImageExecutionUnknown(err) {\n\t\treturn err\n\t}\n\treturn &imageExecutionUnknownError{err: err}\n}\n\n// ListDocumentImages 返回文档引用的本地图片，供智能体工具和编辑器功能复用。\nfunc ListDocumentImages(documentID string) (DocumentImageList, error) {\n\tbt, err := resolveMultimodalDocument(documentID)\n\tif err != nil {\n\t\treturn DocumentImageList{}, err\n\t}\n\tpaths, err := DocImageAssets(bt.RootID)\n\tif err != nil {\n\t\treturn DocumentImageList{}, fmt.Errorf(\"list document images failed: %w\", err)\n\t}\n\trefs := make([]ImageArtifactRef, 0, len(paths))\n\tseen := map[string]bool{}\n\tfor _, assetPath := range paths {\n\t\tif !strings.HasPrefix(AssetPathWithoutQuery(assetPath), \"assets/\") || seen[assetPath] {\n\t\t\tcontinue\n\t\t}\n\t\tseen[assetPath] = true\n\t\trefs = append(refs, ImageArtifactRef{Kind: \"image\", Path: assetPath, DocumentID: bt.RootID})\n\t}\n\treturn DocumentImageList{DocumentID: bt.RootID, Images: refs}, nil\n}\n\n// PrepareDocumentImage 校验并读取文档实际引用的本地资源图片，供当前模型直接接收图片输入。\nfunc PrepareDocumentImage(documentID, assetPath string) (PreparedDocumentImage, error) {\n\tassetPath = strings.TrimSpace(assetPath)\n\tif assetPath == \"\" {\n\t\treturn PreparedDocumentImage{}, errors.New(\"assetPath is required for analyze\")","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/assets.go#L419-L455","documentation":"ListDocumentImages resolves a multimodal document and then enumerates its image assets via DocImageAssets; if that enumeration returns an error it is wrapped as \"list document images failed\". It indicates the document's image inventory could not be built.","triggerScenarios":"Calling ListDocumentImage for a document whose RootID asset scan fails, e.g. the underlying document tree cannot be loaded or the asset index query errors inside DocImageAssets.","commonSituations":"Corrupted or missing .sy file for the document; database/index inconsistency after a failed sync; document deleted between resolution and asset scan.","solutions":["Check kernel logs for the wrapped %w cause to find the underlying failure","Rebuild the asset index / reindex the notebook for the affected document","Verify the document .sy file exists and is valid before retrying the API call"],"exampleFix":"// caller-side guard before calling\nif _, statErr := os.Stat(docPath); statErr != nil { return fmt.Errorf(\"document missing: %w\", statErr) }\npaths, err := ListDocumentImages(docID)","handlingStrategy":"try-catch","validationCode":"if _, err := loadTreeByBlockID(rootID); err != nil { /* document index invalid, reindex first */ }","typeGuard":null,"tryCatchPattern":"list, err := ListDocumentImages(docID)\nif err != nil { log.Errorf(\"document images unavailable: %v\", err); return fallbackImageList(docID) }","preventionTips":["Keep the asset index healthy (reindex after sync conflicts)","Avoid deleting documents while image operations are in flight","Check kernel logs for the wrapped underlying cause"],"tags":["go","assets","documents","indexing"],"backgroundTag":"database-query-failed","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"}