siyuan-note/siyuan · error

image operation failed

Error message

image operation failed

What it means

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.

Source

Thrown at kernel/mcp/tools/image.go:346

	bt := treenode.GetBlockTree(documentID)
	if bt == nil {
		return false
	}
	absPath, err := model.GetAssetAbsPathInBox(assetPath, bt.BoxID)
	return err == nil && filelock.IsExist(absPath)
}

func imageJSON(value any) CallToolResult {
	data, err := json.Marshal(value)
	if err != nil {
		return imageError(err.Error())
	}
	return CallToolResult{Content: []ContentItem{{Type: "text", Text: string(data)}}}
}

func imageError(message string) CallToolResult {
	if message == "" {
		message = errors.New("image operation failed").Error()
	}
	return CallToolResult{Content: []ContentItem{{Type: "text", Text: message}}, IsError: true}
}

func imageResultForError(err error) CallToolResult {
	if model.IsImageExecutionUnknown(err) {
		return imageUnknown(err.Error())
	}
	return imageError(err.Error())
}

func imageUnknown(message string) CallToolResult {
	result := imageError(message)
	result.ExecutionUnknown = true
	return result
}

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Inspect the kernel logs around the call site for the real underlying error (image backends log details before returning).
  2. If you are extending the image tool, always pass `err.Error()` (or a descriptive string) to `imageError`, never an empty value.
  3. Confirm the configured image provider (API key, endpoint) is set up correctly, since provider misconfiguration is the most common root cause.

Example fix

// before
return imageError("")
// after
return imageError(err.Error())
Defensive patterns

Strategy: try-catch

Try / catch

// When wrapping image errors, always propagate a non-empty message.
res := imageResultForError(err)
if !res.IsError || (len(res.Content) > 0 && res.Content[0].Text == "") {
    res = imageError("image operation failed: underlying error was empty")
}
return res

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/3ebf76cc127877b3. Report an issue: GitHub.