{"record":{"id":"3ebf76cc127877b3","repo":"siyuan-note/siyuan","slug":"image-operation-failed","errorCode":null,"errorMessage":"image operation failed","messagePattern":"image operation failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/mcp/tools/image.go","lineNumber":346,"sourceCode":"\tbt := treenode.GetBlockTree(documentID)\n\tif bt == nil {\n\t\treturn false\n\t}\n\tabsPath, err := model.GetAssetAbsPathInBox(assetPath, bt.BoxID)\n\treturn err == nil && filelock.IsExist(absPath)\n}\n\nfunc imageJSON(value any) CallToolResult {\n\tdata, err := json.Marshal(value)\n\tif err != nil {\n\t\treturn imageError(err.Error())\n\t}\n\treturn CallToolResult{Content: []ContentItem{{Type: \"text\", Text: string(data)}}}\n}\n\nfunc imageError(message string) CallToolResult {\n\tif message == \"\" {\n\t\tmessage = errors.New(\"image operation failed\").Error()\n\t}\n\treturn CallToolResult{Content: []ContentItem{{Type: \"text\", Text: message}}, IsError: true}\n}\n\nfunc imageResultForError(err error) CallToolResult {\n\tif model.IsImageExecutionUnknown(err) {\n\t\treturn imageUnknown(err.Error())\n\t}\n\treturn imageError(err.Error())\n}\n\nfunc imageUnknown(message string) CallToolResult {\n\tresult := imageError(message)\n\tresult.ExecutionUnknown = true\n\treturn result\n}\n","sourceCodeStart":328,"sourceCodeEnd":363,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/mcp/tools/image.go#L328-L363","documentation":"Generic fallback message produced by `imageError` when it is called with an empty message string. In practice every real image-tool error is forwarded with its concrete message (`imageResultForError` passes `err.Error()`); this string only appears if some code path called `imageError(\"\")`, signalling an error was reported without a detail message.","triggerScenarios":"An image-tool code path invokes `imageError(\"\")` — i.e. constructs an error result without supplying a message. The underlying image operation (generation/processing via `model`) failed but the specific reason was not propagated.","commonSituations":"An image backend returned an error that was swallowed and re-reported as an empty string. A code path that creates an error result from a nil/empty error variable. A future regression where a new failure mode forgets to set the message.","solutions":["Inspect the kernel logs around the call site for the real underlying error (image backends log details before returning).","If you are extending the image tool, always pass `err.Error()` (or a descriptive string) to `imageError`, never an empty value.","Confirm the configured image provider (API key, endpoint) is set up correctly, since provider misconfiguration is the most common root cause."],"exampleFix":"// before\nreturn imageError(\"\")\n// after\nreturn imageError(err.Error())","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// When wrapping image errors, always propagate a non-empty message.\nres := imageResultForError(err)\nif !res.IsError || (len(res.Content) > 0 && res.Content[0].Text == \"\") {\n    res = imageError(\"image operation failed: underlying error was empty\")\n}\nreturn res","preventionTips":["Always pass err.Error() to imageError, never an empty string.","Inspect kernel logs for the real underlying image-provider error.","Verify the image provider (API key, endpoint) is configured."],"tags":["mcp","image","error-handling","fallback"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}