OpenHands/OpenHands · error · AggregateError
Failed to disable the imported automation and clean it up.
Error message
Failed to disable the imported automation and clean it up.
What it means
AggregateError thrown during createAutomation when the initial PATCH (to set the real trigger and disable the automation) fails AND the subsequent DELETE cleanup also fails. The AggregateError contains both errors: [updateError, cleanupError]. This represents a partially-created automation that could not be cleaned up — the automation record exists in a pending/placeholder state on the server.
Source
Thrown at src/api/automation-service/automation-service.api.ts:371
);
return data;
} catch (updateError) {
try {
if (active.backend.kind === "cloud") {
await callCloudProxy<unknown>({
backend: active.backend,
method: "DELETE",
path: updatePath,
headers: await buildPinnedCloudHeaders(active),
});
} else {
await localAutomationAxios.delete(
updatePath,
await buildPinnedLocalConfig(active.backend),
);
}
} catch (cleanupError) {
throw new AggregateError(
[updateError, cleanupError],
"Failed to disable the imported automation and clean it up.",
);
}
throw updateError;
}
}
static async updateAutomation(
id: string,
body: Partial<Automation>,
): Promise<Automation> {
const active = getActiveBackend().backend;
const path = `${AUTOMATION_BASE_PATH}${getAutomationIdEndpoint("detail", id)}`;
if (active.kind === "cloud") {
return callCloudProxy<Automation>({
backend: active,View on GitHub (pinned to 500b4c533e)
Solutions
- Check the AggregateError.errors array — the first error is the PATCH failure, the second is the DELETE failure — to diagnose the root cause.
- Manually clean up the orphaned automation record via DELETE /api/automation/v1/automations/{id} using the created automation's ID (visible in server logs).
- Restart the automation backend (uvx process) if it crashed, then retry the import.
- Verify the automation backend version matches the SDK version expected by Canvas (npm run check-sdk-version-sync).
Example fix
// handling the aggregate error
try {
await AutomationService.createAutomation(spec);
} catch (error) {
if (error instanceof AggregateError) {
console.error('PATCH failed:', error.errors[0]);
console.error('Cleanup DELETE also failed:', error.errors[1]);
// manually clean up the orphaned record if possible
}
throw error;
} Defensive patterns
Strategy: try-catch
Type guard
function isAggregateError(e: unknown): e is AggregateError {
return typeof AggregateError !== 'undefined' && e instanceof AggregateError;
} Try / catch
try {
await AutomationService.createAutomation(spec);
} catch (error) {
if (error instanceof AggregateError) {
const [updateErr, cleanupErr] = error.errors;
console.error('Import failed:', updateErr);
console.error('Cleanup also failed — orphaned record may exist:', cleanupErr);
// Attempt manual cleanup if the created ID is known
}
throw error;
} Prevention
- Check automation backend health before importing — if it's unhealthy, both PATCH and DELETE will fail.
- After an AggregateError, list automations to find and manually delete orphaned placeholder records.
- Keep the automation backend version in sync with the agent-server SDK version (npm run check-sdk-version-sync).
When it happens
Trigger: createAutomation does a two-step: POST to create with a placeholder trigger, then PATCH to set the real trigger and disable it. If the PATCH fails (network error, server error, validation error), it tries DELETE to clean up. If the DELETE also fails, this AggregateError is thrown with both errors. The automation record is left orphaned on the server.
Common situations: Agent-server or automation backend restarts between the POST and PATCH; the automation backend has a schema mismatch that accepts the POST but rejects the PATCH; network instability causes both the PATCH and DELETE to time out; the automation backend process crashed after the POST but before the PATCH.
Related errors
AI-assisted analysis of OpenHands/OpenHands@500b4c533e (2026-08-12).
Data as JSON: /api/errors/fd945a0a9cb42690.
Report an issue: GitHub.