Skip to content

Comments

fix: Preserve error chains across error wrapping boundaries#215

Draft
dcramer wants to merge 1 commit intomainfrom
warden-sweep/cd745cc3/error-chains
Draft

fix: Preserve error chains across error wrapping boundaries#215
dcramer wants to merge 1 commit intomainfrom
warden-sweep/cd745cc3/error-chains

Conversation

@dcramer
Copy link
Member

@dcramer dcramer commented Feb 23, 2026

Six locations wrapped errors without passing { cause: error }, breaking error chain traversal for debugging and Sentry reporting. Also adds a code property to ExecError for structured errno access.

Changes

  • src/cli/git.ts: Add { cause: error } to git() wrapper
  • src/sdk/errors.ts: Update WardenAuthenticationError to accept { cause } option
  • src/sdk/auth.ts: Pass cause to WardenAuthenticationError throws
  • src/sdk/analyze.ts: Pass cause when rethrowing auth errors
  • src/skills/remote.ts: Pass cause to SkillLoaderError in execGit
  • src/evals/index.ts: Pass cause to file read error wrapper
  • src/utils/exec.ts: Add code property to ExecError, populate from spawn errors

Automated fix for Warden findings bf3caddd, 811a555f, 410d3c52, 91113dcf, ebd7c6df, cd7521bb (medium, detected by find-warden-bugs).

Ref #212

This PR was auto-generated by a Warden Sweep (run cd745cc3).
The finding has been validated through automated deep tracing,
but human confirmation is requested as this is batch work.

Six locations wrapped errors without passing { cause: error }, breaking
error chain traversal for debugging and Sentry reporting. Also adds
code property to ExecError for structured errno access.

Warden findings: bf3caddd, 811a555f, 410d3c52, 91113dcf, ebd7c6df, cd7521bb
Severity: medium

Co-Authored-By: Warden <noreply@getsentry.com>

if (result.error) {
throw new ExecError(command, null, result.error.message, null);
throw new ExecError(command, null, result.error.message, null, (result.error as NodeJS.ErrnoException).code);
Copy link
Contributor

Choose a reason for hiding this comment

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

ExecError wrapping discards original error chain

The PR claims to fix error chain preservation, but lines 73 and 107 still wrap result.error without passing { cause: result.error }. Additionally, the ExecError constructor (line 6-18) doesn't accept an options parameter to support { cause } - the super() call only passes the message string, not options. This breaks error chain traversal for debugging and Sentry reporting when spawn errors occur.

Verification

Read src/utils/exec.ts and verified: (1) The ExecError constructor at lines 6-18 has signature constructor(command, exitCode, stderr, signal, code?) with no options parameter for cause. (2) The super() call at line 15 passes only the message, not { cause }. (3) Lines 73 and 107 pass result.error.message and the code but not the error itself as cause.

Suggested fix: Update ExecError constructor to accept an options parameter with cause, and pass the original error when throwing

Suggested change
throw new ExecError(command, null, result.error.message, null, (result.error as NodeJS.ErrnoException).code);
public readonly code?: string,
options?: { cause?: unknown }
super(`Command failed: ${command}\n${details}`, options);

Identified by Warden find-warden-bugs · QV3-B7G

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

warden Automated fix from Warden Sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant