Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/sandboxes/runClaudeCodeAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,20 @@ export async function runClaudeCodeAgent(
},
};

const command = await sandbox.runCommand(commandOpts as any);
let command;
try {
command = await sandbox.runCommand(commandOpts as any);
} catch (error) {
logStep(`${label} - sandbox.runCommand failed`, false, {
error: error instanceof Error ? error.message : String(error),
sandboxId: sandbox.sandboxId,
cwd,
cmd: "claude",
argsLength: args.length,
messageLength: message.length,
});
throw error;
Comment on lines +50 to +58
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Preserve the original runCommand error if step logging fails.

Line 50 logging is inside the catch path; if logStep() throws, it can mask the root sandbox.runCommand failure. Make this diagnostics logging best-effort, then rethrow the original error.

Suggested fix
   } catch (error) {
-    logStep(`${label} - sandbox.runCommand failed`, false, {
-      error: error instanceof Error ? error.message : String(error),
-      sandboxId: sandbox.sandboxId,
-      cwd,
-      cmd: "claude",
-      argsLength: args.length,
-      messageLength: message.length,
-    });
+    try {
+      logStep(`${label} - sandbox.runCommand failed`, false, {
+        error: error instanceof Error ? error.message : String(error),
+        sandboxId: sandbox.sandboxId,
+        cwd,
+        cmd: "claude",
+        argsLength: args.length,
+        messageLength: message.length,
+      });
+    } catch {
+      // Best-effort logging only; do not mask the original failure.
+    }
     throw error;
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/sandboxes/runClaudeCodeAgent.ts` around lines 50 - 58, The catch block
that reports a failed sandbox.runCommand call should not allow logStep failures
to replace the original error; wrap the logStep(...) call in its own try/catch
so logging is best-effort and any exception thrown by logStep is swallowed or
recorded separately, then rethrow the original error variable (error) from the
catch in runClaudeCodeAgent.ts; ensure you reference the existing symbols
logStep, sandbox.runCommand, and the caught error variable so the original error
is always propagated.

}
const result = await command.wait();

const stdout = (await result.stdout()) || "";
Expand Down
Loading