mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-21 02:43:25 +01:00
fix(environments): clean up an unconfirmed setup sandbox and answer a provider outage with 503 (#22377)
A provider outage during an interactive custom-image setup start left a provisional sandbox with no cleanup owner, and the raw RPC error reached the HTTP error handler as a 500 crash report. - Keep the creation-cleanup envelope and create status for environmentStartInteractiveSetup errors at the worker RPC boundary. - Record an in-scope unconfirmed setup sandbox as a pending-cleanup lease that the existing sweep destroys. - Pin failed-creation cleanup (probe and teardown) to the plugin that created the sandbox. - Answer a transient provider refusal with 503 environment_provider_unavailable instead of a crash report. Co-Authored-By: Paperclip <Paperclip-Paperclip@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
10 files changed
+309
-10
No files matched your search
@@ -21,6 +21,7 @@ import { recordResponsibleUserDenialOnActiveRun } from "../services/responsible-
|
||||
import { isObjectJournalBusyError } from "../services/object-byte-journal.js";
|
||||
import { isExpectedMcpConnectionFailure } from "../services/mcp-connection-failure.js";
|
||||
import { isOpenRouterCatalogUnavailable } from "../services/openrouter-models.js";
|
||||
import { ENVIRONMENT_PROVIDER_UNAVAILABLE_CODE, readTransientSandboxCreationRefusal } from "../services/environment-provider-unavailable-error.js";
|
||||
import { isEndedDbPoolError } from "../database-retry.js";
|
||||
import { ToolGatewayHttpError } from "../services/tool-gateway.js";
|
||||
|
||||
@@ -340,6 +341,20 @@ export function errorHandler(
|
||||
return;
|
||||
}
|
||||
|
||||
// A sandbox provider outage during a sandbox creation that this request
|
||||
// started is not a server fault. The answer is fixed text: provider text and
|
||||
// provisional sandbox names stay out, and cleanup stays with its own record.
|
||||
const providerRefusal = readTransientSandboxCreationRefusal(rootError);
|
||||
if (providerRefusal) {
|
||||
if (!res.headersSent) {
|
||||
res.set("Retry-After", "30");
|
||||
res.status(503).json({ error: providerRefusal.message, code: ENVIRONMENT_PROVIDER_UNAVAILABLE_CODE });
|
||||
} else {
|
||||
res.end();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const reportableError = sanitizeSecretSensitiveError(req, rootError);
|
||||
attachErrorContext(
|
||||
req,
|
||||
|
||||
Reference in new issue
Block a user