mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
fix(presentation): ask the person to connect GitHub when a clone is refused
A clone that GitHub refused (git=auth_failed or git=repository_not_found at stage=clone) finished the run as the generic setup_failed. The task showed only "Couldn't finish this attempt" with Retry, and automatic continuation kept trying a clone that cannot work. Classify these clone failures as github_auth_required and github_repo_not_accessible. Both codes are already person-owned, so automatic continuation and transient retry stop. Present them as a connect_github user action, and show the reason with a Connect GitHub link and a secondary Retry. Refs #19368 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
278660149c
commit
bf0ae68688
9 files changed
+96
-2
No files matched your search
@@ -165,13 +165,14 @@ export interface TaskInterruptionPresentation {
|
||||
nextRetryAt: string | null;
|
||||
canRetry: boolean;
|
||||
retryAction?: "move_forward";
|
||||
userAction: "approval" | "reconnect" | "assign_agent" | "choose_model" | "resume" | "budget" | "project_access"
|
||||
userAction: "approval" | "reconnect" | "assign_agent" | "choose_model" | "resume" | "budget" | "project_access" | "connect_github"
|
||||
/** Board confirms that a previous server, which can no longer report, stopped its workspace copyback. */
|
||||
| "confirm_owner_stop"
|
||||
/** Board confirms that a run whose server restarted before it recorded the agent's process has stopped. */
|
||||
| "confirm_run_stopped" | null;
|
||||
/** Only the task's own project id is exposed. Other source projects stay unnamed. */
|
||||
projectAccess?: { agentId: string; projectId: string | null; ready: boolean };
|
||||
githubAccess?: "github_auth_required" | "github_repo_not_accessible";
|
||||
sourceRunIds: string[];
|
||||
observedRunId: string | null;
|
||||
/** The saved-work recovery step that must finish before the task continues. */
|
||||
|
||||
@@ -26,6 +26,7 @@ import { UnresolvedWorkspaceBaseRefError } from "../workspace-runtime.js";
|
||||
import { LegacyControllerLeaseLostError } from "../legacy-controller-lease.js";
|
||||
import { requestedRunCancellation } from "../run-cancellation.js";
|
||||
import { ProjectAccessDeniedError } from "../project-access-denial.js";
|
||||
import { isSystemOwnedFailureCode } from "../continuation-cause.js";
|
||||
import { RemoteWorkspaceOperationError, RemoteWorkspaceOperationTimeoutError, RemoteWorkspacePreparationTimeoutError, RemoteWorkspaceRestoreError } from "../remote-workspace-transport.js";
|
||||
import { EnvironmentRunError, environmentRunOrchestrator } from "../environment-run-orchestrator.js";
|
||||
import { ReusableSandboxResumeError } from "../reusable-sandbox-resume-error.js";
|
||||
@@ -1131,6 +1132,32 @@ describe.skipIf(!support.supported && !process.env.PAPERCLIP_TEST_DATABASE_URL)(
|
||||
expect(f.deps.finalizeIssueCommentPolicy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([
|
||||
["auth_failed", "github_auth_required"],
|
||||
["repository_not_found", "github_repo_not_accessible"],
|
||||
] as const)("names a clone that GitHub refused with git=%s as %s and does not retry it", async (git, errorCode) => {
|
||||
const f = await fixture();
|
||||
const error = new RemoteWorkspaceOperationError(
|
||||
`remote_workspace_operation_failed: operation=prepare exit=1; remote_workspace_prepare_failed: stage=clone git=${git} exit=128 program=git`);
|
||||
await f.completion.failRunSetup(f.setup(error));
|
||||
const failed = await read(f.run.id);
|
||||
expect(failed).toMatchObject({ status: "failed", errorCode,
|
||||
resultJson: { executionRecovery: { kind: "bootstrap", providerWorkStarted: false } } });
|
||||
expect(isSystemOwnedFailureCode(failed.errorCode)).toBe(false);
|
||||
expect(f.deps.scheduleBoundedRetryForRun).not.toHaveBeenCalled();
|
||||
expect(f.deps.enqueueWakeup).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([
|
||||
new RemoteWorkspaceOperationError("remote_workspace_operation_failed: operation=prepare exit=1; remote_workspace_prepare_failed: stage=clone git=network exit=128 program=git"),
|
||||
new RemoteWorkspaceOperationError("remote_workspace_operation_failed: operation=prepare exit=1; remote_workspace_prepare_failed: stage=fetch git=auth_failed exit=128 program=git"),
|
||||
new Error("remote_workspace_operation_failed: operation=prepare exit=1; remote_workspace_prepare_failed: stage=clone git=auth_failed exit=128 program=git"),
|
||||
])("keeps another or untrusted workspace failure a generic setup failure: %s", async error => {
|
||||
const f = await fixture();
|
||||
await f.completion.failRunSetup(f.setup(error));
|
||||
expect(await read(f.run.id)).toMatchObject({ status: "failed", errorCode: "setup_failed" });
|
||||
});
|
||||
|
||||
it("records a setup configuration gap without inventing provider work or applying comment policy", async () => {
|
||||
const f = await fixture();
|
||||
await f.completion.failRunSetup(f.setup(new ConfigurationIncompleteFailure("missing credential", { configurationIncomplete: { reason: "missing_binding" } })));
|
||||
|
||||
@@ -18,7 +18,7 @@ import { pendingCaseHandoffForRun } from "./case-handoff-lifecycle.js";
|
||||
import { NON_RETRYABLE_PREFLIGHT_FAILURE_CODES, isHeartbeatRunTerminalStatus } from "./run-lifecycle.js";
|
||||
import { ChatControlRecoveryUnresolvedError } from "./queue.js";
|
||||
import { readTransientRecoveryContractFromRun, readHeartbeatRunErrorFamily, isTransientWorkspacePreparationCode } from "./retries.js";
|
||||
import { RemoteWorkspacePreparationTimeoutError, REMOTE_WORKSPACE_RESTORE_FAILED_CODE, findRemoteWorkspaceRestoreError } from "../remote-workspace-transport.js";
|
||||
import { RemoteWorkspacePreparationTimeoutError, REMOTE_WORKSPACE_RESTORE_FAILED_CODE, findRemoteWorkspaceCloneAccessFailure, findRemoteWorkspaceRestoreError } from "../remote-workspace-transport.js";
|
||||
import { escalateRemoteWorkspaceRestoreFailure } from "../remote-workspace-restore-recovery.js";
|
||||
import { findReusableSandboxResumeError } from "../reusable-sandbox-resume-error.js";
|
||||
import { findPluginWorkerUnavailableError, PLUGIN_WORKER_UNAVAILABLE_CODE } from "../plugin-worker-unavailable-error.js";
|
||||
@@ -1690,6 +1690,7 @@ export function createHeartbeatRunCompletion(db: Db, dependencies: HeartbeatRunC
|
||||
: null) ??
|
||||
recordedResponsibleUserDenialCode ??
|
||||
nonRetryablePreflightCode ??
|
||||
findRemoteWorkspaceCloneAccessFailure(outerErr) ??
|
||||
"setup_failed";
|
||||
const failureCause = GENERIC_RUN_FAILURE_CODES.has(setupFailureErrorCode) ? thrownFailureCause : null;
|
||||
// Bounded kind and reason only: a workspace provider's own text never crosses into Core.
|
||||
|
||||
@@ -153,6 +153,17 @@ export function findRemoteWorkspaceRestoreError(error: unknown): RemoteWorkspace
|
||||
return null;
|
||||
}
|
||||
|
||||
const CLONE_ACCESS_FAILURE = /; remote_workspace_(?:prepare|repository)_failed: stage=clone(?: [a-z_]+=[A-Za-z0-9_]+)*? git=(auth_failed|repository_not_found)(?: |$)/;
|
||||
|
||||
export function findRemoteWorkspaceCloneAccessFailure(error: unknown): "github_auth_required" | "github_repo_not_accessible" | null {
|
||||
for (let cause = error, depth = 0; cause && depth < 4; cause = (cause as { cause?: unknown }).cause, depth++) {
|
||||
if (!(cause instanceof RemoteWorkspaceOperationError)) continue;
|
||||
const git = CLONE_ACCESS_FAILURE.exec(remoteWorkspaceFailureCause(cause) ?? "")?.[1];
|
||||
if (git) return git === "auth_failed" ? "github_auth_required" : "github_repo_not_accessible";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const TRANSPORT_FAILURE_LABELS: Array<[RegExp, string]> = [
|
||||
[/daytona_sandbox_not_found/i, "daytona_sandbox_not_found"],
|
||||
[/sandbox lease \S+ is no longer active/i, "sandbox_lease_inactive"],
|
||||
|
||||
@@ -595,3 +595,20 @@ describe("hand-off of a run that failed before any provider work", () => {
|
||||
.toMatchObject({ state: "failed", canRetry: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe("task GitHub access interruption", () => {
|
||||
it.each(["github_auth_required", "github_repo_not_accessible"] as const)("asks the person to fix the GitHub connection for %s, keeping Retry", errorCode => {
|
||||
const failed = { ...run, errorCode, resultJson: { executionRecovery: { kind: "bootstrap", providerWorkStarted: false } } };
|
||||
expect(projectTaskInterruption(issue, { run: failed, agent, paused: false, approval: false })).toMatchObject({
|
||||
state: "waiting_for_user", responsibility: "user", userAction: "connect_github", canRetry: true, githubAccess: errorCode,
|
||||
});
|
||||
});
|
||||
|
||||
it("shows an accepted Retry as working and keeps a generic setup failure generic", () => {
|
||||
const failed = { ...run, errorCode: "github_auth_required", resultJson: null };
|
||||
expect(projectTaskInterruption(issue, { run: failed, agent, paused: false, approval: false,
|
||||
wait: { id: "request", requestedAt: new Date() } })).toMatchObject({ state: "working", canRetry: false });
|
||||
expect(projectTaskInterruption(issue, { run: { ...failed, errorCode: "setup_failed" }, agent, paused: false, approval: false }))
|
||||
.toMatchObject({ state: "failed", responsibility: "system", userAction: null, canRetry: true });
|
||||
});
|
||||
});
|
||||
@@ -404,6 +404,9 @@ function projectTaskInterruptionState(issue: ProjectionIssue, input: ProjectionS
|
||||
return { ...base, state: "failed", canRetry: false,
|
||||
retryWait: { reason: "cleanup_quarantined", message: NATIVE_CLEANUP_SETTLING_MESSAGE } };
|
||||
}
|
||||
if (run.status === "failed" && (run.errorCode === "github_auth_required" || run.errorCode === "github_repo_not_accessible"))
|
||||
return { ...base, responsibility: "user", state: "waiting_for_user", canRetry: true, userAction: "connect_github",
|
||||
githubAccess: run.errorCode };
|
||||
return { ...base, state: "failed", canRetry: true, ...(projectAccess ? { projectAccess } : {}) };
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,25 @@ describe("ordinary task interruption", () => {
|
||||
await act(async () => container.querySelector<HTMLButtonElement>("button")!.click());
|
||||
expect(retry).toHaveBeenCalledOnce();
|
||||
});
|
||||
it("names a missing GitHub connection with one Connect GitHub step and a secondary Retry", async () => {
|
||||
await render({ ...failed, responsibility: "user", state: "waiting_for_user", userAction: "connect_github", githubAccess: "github_auth_required" });
|
||||
expect(container.textContent).toContain("Couldn’t get this project’s repository from GitHub. Connect your GitHub account, then retry. Your message is saved.");
|
||||
expect(container.textContent).not.toContain("Couldn’t finish this attempt.");
|
||||
const connect = container.querySelector<HTMLAnchorElement>('[data-testid="task-execution-connect-github"]');
|
||||
expect(connect?.textContent).toBe("Connect GitHub");
|
||||
expect(connect?.getAttribute("href")).toBe("/apps/connect?source=github");
|
||||
await act(async () => container.querySelector<HTMLButtonElement>('[data-testid="task-execution-retry"]')!.click());
|
||||
expect(retry).toHaveBeenCalledOnce();
|
||||
await render({ ...failed, responsibility: "user", state: "waiting_for_user", userAction: "connect_github", githubAccess: "github_auth_required" }, { canRetry: false });
|
||||
expect(container.querySelector("button")).toBeNull();
|
||||
expect(container.querySelector('[data-testid="task-execution-connect-github"]')).not.toBeNull();
|
||||
});
|
||||
it("names a GitHub repository the connection cannot reach", async () => {
|
||||
await render({ ...failed, responsibility: "user", state: "waiting_for_user", userAction: "connect_github", githubAccess: "github_repo_not_accessible" });
|
||||
expect(container.textContent).toContain("Your GitHub account can’t reach this repository. Check the repository and its access in the GitHub connection, then retry.");
|
||||
expect(container.textContent).not.toContain("Couldn’t finish this attempt.");
|
||||
expect(container.querySelector('[data-testid="task-execution-connect-github"]')?.getAttribute("href")).toBe("/apps/connect?source=github");
|
||||
});
|
||||
it("shows why an accepted Retry is waiting and keeps another attempt available", async () => {
|
||||
const retryWait = { reason: "remote_cleanup", message: "Retry is waiting for the previous environment to stop. Your message is saved." };
|
||||
await render({ ...failed, retryWait });
|
||||
|
||||
@@ -11,6 +11,7 @@ import { ProviderFailureNotice } from "./ProviderFailureNotice";
|
||||
import { LockedIssueChip, isLockedIssueStub } from "./LockedIssueChip";
|
||||
import { PreviousServerStopConfirmation } from "./WorkspaceExportRecovery";
|
||||
import { issuesApi } from "../api/issues";
|
||||
import { appSourceConnectHref } from "../pages/apps/app-connect-policy";
|
||||
|
||||
const recoveryStepText: Record<NonNullable<TaskInterruptionPresentation["recoveryStep"]>, string> = {
|
||||
checking_previous_run: "Checking that the previous attempt stopped",
|
||||
@@ -106,6 +107,19 @@ export function ExecutionBlockerNotice({ presentation, canRetry, onRetry, optimi
|
||||
placeholder: "For example: no codex or claude process for this task is running on the server host.",
|
||||
resuming: "Starting your Retry…", confirm: "Confirm it stopped" }} />;
|
||||
}
|
||||
if (!optimistic && presentation?.state === "waiting_for_user" && presentation.userAction === "connect_github") return (
|
||||
<div className={cn("pt-4", className)}>
|
||||
<div role="status" aria-label="Task status" data-testid="task-execution-waiting"
|
||||
className="flex items-center justify-between gap-3 rounded-lg bg-destructive/10 p-4 text-sm text-foreground">
|
||||
<AlertCircle className="size-5 shrink-0 text-destructive" aria-hidden="true" />
|
||||
<span className="min-w-0 flex-1">{presentation.githubAccess === "github_repo_not_accessible"
|
||||
? "Your GitHub account can’t reach this repository. Check the repository and its access in the GitHub connection, then retry."
|
||||
: "Couldn’t get this project’s repository from GitHub. Connect your GitHub account, then retry. Your message is saved."}</span>
|
||||
{canRetry && presentation.canRetry && <Button variant="outline" size="sm" className="shrink-0" onClick={onRetry} data-testid="task-execution-retry">Retry</Button>}
|
||||
<Button asChild size="sm" className="shrink-0"><Link to={appSourceConnectHref("github")} data-testid="task-execution-connect-github">Connect GitHub</Link></Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
// Other person-owned decisions have their own card on the task (approval,
|
||||
// project access, ...). A budget hold has none, so name it here and keep the
|
||||
// failure visible. The saved attempt starts by itself once the budget allows.
|
||||
|
||||
@@ -415,6 +415,7 @@ export function FailedRunInboxRow({
|
||||
approval: "Approval required", reconnect: "Reconnect account", assign_agent: "Assign an agent", choose_model: "Choose a supported model",
|
||||
resume: "Work is paused", budget: "Budget limit reached",
|
||||
project_access: "Agent needs project access",
|
||||
connect_github: "Connect GitHub",
|
||||
confirm_owner_stop: "Confirm the previous server stopped",
|
||||
confirm_run_stopped: "Confirm the previous run stopped",
|
||||
}[interruption.userAction ?? "resume"]) : runFailureMessage(run);
|
||||
|
||||
Reference in new issue
Block a user