siyuan-note/siyuan · error
Plugin returned an invalid action
Error message
Plugin ${pluginLabel} returned an invalid action What it means
In processPlugin, after waiting for a plugin's decision on an asset-upload conflict, only actions "cancel" and "replace" are accepted. If the plugin resolves with any other (or an unrecognized) action value, the code throws 'Plugin ${pluginLabel} returned an invalid action'. This enforces the plugin-decision protocol for asset uploads.
Solutions
- Fix the plugin to return only "cancel" or "replace" as the action value in its decision object
- Return null/undefined from the plugin handler instead of an object when no decision is made (null decision bypasses both checks)
- Update the plugin to the current siyuan plugin API version and check plugin-sample for the correct decision shape
- Log the received decision object in the plugin to identify what action value it actually returns
Example fix
// before (in plugin)
return {action: "overwrite", input};
// after
return {action: "replace", input}; Defensive patterns
Strategy: validation
Validate before calling
function isValidDecision(d) {
return d === null || d === undefined ||
(typeof d === "object" && (d.action === "cancel" || d.action === "replace"));
} Type guard
type PluginDecision = {action: "cancel"} | {action: "replace", input: unknown} | null;
const isPluginDecision = (d: unknown): d is PluginDecision =>
d === null || (typeof d === "object" && d !== null &&
["cancel", "replace"].includes((d as any).action)); Try / catch
processPlugin(...).catch(err => {
if (String(err.message).includes("returned an invalid action")) {
console.error("Plugin decision protocol violated:", err.message);
cancelUpload();
} else { throw err; }
}); Prevention
- Only return "cancel" or "replace" as action values from plugin handlers
- Return null when no decision is needed
- Test plugins against the current plugin API version
- Type the decision return value in the plugin with the official petal types
When it happens
Trigger: A plugin's event handler for the asset-upload decision resolves waitForDecision with an object whose action is neither "cancel" nor "replace" (e.g. "skip", "overwrite", typo, or undefined action with a non-null decision object).
Common situations: A plugin author returns a custom action name expecting it to be honored; a plugin version predates the current decision protocol; a bug where decision = {action: null} but decision itself is truthy.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Plugin returned invalid input
- Plugin returned invalid input
- Account authentication failed, please login again
- asset path is sensitive
- BASE64_IMAGE_SIZE_LIMIT
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/32836d20283c8de8.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/protyle/upload/pluginEvent.ts:437
discardResponse();
return fail(new Error(`Plugin ${pluginLabel} must use respondWith to replace or cancel an asset upload`));
}
if (responseError) {
discardResponse();
return fail(responseError);
}
if (emitResult.hasAsyncListener && !responseClaimed) {
return fail(new Error(`Plugin ${pluginLabel} must call respondWith synchronously before awaiting`));
}
if (!response) {
return processPlugin(index + 1);
}
return waitForDecision(response, task, pluginLabel, timeout).then(decision => {
if (decision?.action === "cancel") {
return cancel();
}
if (decision?.action !== "replace") {
throw new Error(`Plugin ${pluginLabel} returned an invalid action`);
}
const validationError = validateAssetUploadInput(decision.input);
if (validationError) {
throw new Error(`Plugin ${pluginLabel} returned invalid input: ${validationError}`);
}
const targetValidationError = validateTargetInput(decision.input, context);
if (targetValidationError) {
throw new Error(`Plugin ${pluginLabel} returned invalid input: ${targetValidationError}`);
}
task.input = cloneInput(decision.input);
return processPlugin(index + 1);
}).catch(error => error instanceof AssetUploadCanceledError ? cancel(error.message) : fail(error));
};
return processPlugin(0);
};
View on GitHub (pinned to 9f775e8a12)