diff --git a/src/lib/onboard/sandbox-provider-cleanup.ts b/src/lib/onboard/sandbox-provider-cleanup.ts index d23b4482516..74373890756 100644 --- a/src/lib/onboard/sandbox-provider-cleanup.ts +++ b/src/lib/onboard/sandbox-provider-cleanup.ts @@ -70,7 +70,7 @@ const TOLERATED_DETACH_OUTPUT_RE = const MISSING_SANDBOX_OUTPUT_RE = /sandbox[^\n]{0,200}?(?:\bNotFound\b|\bnot\s+found\b)/i; -const ATTACHED_TO_SANDBOX_RE = /attached\s+to\s+sandbox\(\s*es?\s*\)?\s*:\s*([^"\n]+)/i; +const ATTACHED_TO_SANDBOX_RE = /attached\s+to(?:\s|│)+sandbox\(\s*es?\s*\)?\s*:\s*([^"\n]+)/i; const MAX_WARNING_OUTPUT_CHARS = 500; diff --git a/test/sandbox-provider-cleanup.test.ts b/test/sandbox-provider-cleanup.test.ts index 761bc8c734f..e6dac9e2340 100644 --- a/test/sandbox-provider-cleanup.test.ts +++ b/test/sandbox-provider-cleanup.test.ts @@ -304,6 +304,14 @@ describe("parseAttachedSandboxes", () => { expect(parseAttachedSandboxes(output)).toEqual(["spark-nemo"]); }); + it("parses an OpenShell diagnostic wrapped with continuation markers", () => { + const output = + "Error: × code: 'The system is not in a state required for the operation's\n" + + "│ execution', message: \"provider 'compatible-endpoint' is attached to\n" + + '│ sandbox(es): e2e-diag"'; + expect(parseAttachedSandboxes(output)).toEqual(["e2e-diag"]); + }); + it("parses multiple sandbox names from the same diagnostic", () => { const output = "provider 'x' is attached to sandbox(es): alpha, beta, gamma"; expect(parseAttachedSandboxes(output)).toEqual(["alpha", "beta", "gamma"]); @@ -382,7 +390,7 @@ describe("deleteProviderWithRecovery", () => { expect(result.recoveryFailures).toEqual([]); }); - it("parses attached sandbox(es) and retries delete after force-detach", () => { + it("retries delete after force-detaching a sandbox from a wrapped diagnostic", () => { let attempt = 0; const calls: string[][] = []; const runOpenshell = vi.fn((args: string[]) => { @@ -394,7 +402,9 @@ describe("deleteProviderWithRecovery", () => { status: 1, stdout: "", stderr: - "Error: status: FailedPrecondition, message: \"provider 'p' is attached to sandbox(es): orphan-one\"", + "Error: × code: 'The system is not in a state required for the operation's\n" + + "│ execution', message: \"provider 'p' is attached to\n" + + '│ sandbox(es): orphan-one"', }; } return { status: 0, stdout: "", stderr: "" };