siyuan-note/siyuan · error

Plugin ${pluginLabel} returned invalid input: ${targetValida

Error message

Plugin ${pluginLabel} returned invalid input: ${targetValidationError}

What it means

Thrown by processPlugin in the asset upload pipeline when a plugin's upload decision passes basic shape validation (validateAssetUploadInput) but fails target-aware validation (validateTargetInput), e.g. the input references a target document/block that does not exist or is not acceptable in the current context. The original plugin error message is embedded so the plugin author's mistake is identifiable. This keeps malformed plugin output from entering the core upload flow.

Source

Thrown at app/src/protyle/upload/pluginEvent.ts:447

            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 8641553a1f)

Solutions

  1. Read the embedded targetValidationError message and fix the plugin's decision.input to reference an existing, valid target for the context
  2. In the plugin, verify the target document/block ID via the kernel API before returning the decision
  3. Re-check the plugin against the current upload input schema and add target validation of its own before resolving
  4. If you are the host integrator, surface the error to the plugin author rather than retrying; retrying cannot succeed with the same input

Example fix

// before (plugin returns stale target)
return { input: { targetId: deletedDocId, files } };
// after (plugin verifies target first)
const target = await fetchSyncPost("/api/filetree/getDoc", { id: targetId });
if (target.code !== 0) throw new Error(`target ${targetId} no longer exists`);
return { input: { targetId, files } };
Defensive patterns

Strategy: validation

Validate before calling

// in the plugin, before returning the decision
if (!input.targetId || !(await targetExists(input.targetId))) {
  throw new Error(`invalid upload target: ${input.targetId}`);
}

Try / catch

try {
  await prepareAssetUpload(plugin);
} catch (e) {
  if (String(e.message).startsWith("Plugin ")) showPluginError(e.message); // plugin-author bug
}

Prevention

When it happens

Trigger: A plugin's handleAssetUpload (or equivalent decision callback) resolves with decision.input whose fields reference an invalid or missing upload target for the given context; validateTargetInput(decision.input, context) returns a non-empty error string.

Common situations: Plugins written against an older upload-input schema; plugins hardcoding document/block IDs that were deleted; plugins racing with document deletion so the target no longer exists when validation runs.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/54086b2e1fe77738. Report an issue: GitHub.