Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### 🐛 Fixed

- **A rethrown error keeps the one that caused it.** Five places wrapped a
caught error in a new `Error` carrying only its `.message` — settings and
trust-store loading, the hook trust file, and the MCP `headersHelper` — so a
parse failure or a spawn error arrived with the original stack, `errno` and
`path` discarded. They now pass `{ cause }`, and ESLint's `preserve-caught-error`
keeps the next one from being written.

- **Tool output could flood the model's context, or vanish** (#268). Two defects,
one cause: nothing central bounded what a tool result put in front of the
model, so each tool improvised.
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/workspace-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export async function collectWorkspaceDiff(cwd: string): Promise<WorkspaceDiffRe
const files: WorkspaceDiffFile[] = [];

for (const entry of selected) {
let patch = '';
let binary = false;
let patch: string;
let binary: boolean;
let fileTruncated = false;
if (entry.untracked || !hasHead) {
const captured = await addedFilePatch(workspace, entry.path, remainingBytes);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"prepare": "husky || true"
},
"devDependencies": {
"@eslint/js": "^9.16.0",
"@eslint/js": "^10.0.1",
"@types/node": "^22.10.0",
"eslint": "^10.8.0",
"husky": "^9.1.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/config/hook-trust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export class HookTrustStore {
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
return { version: 1, directories: {} };
}
throw new Error(`Failed to load hook trust: ${(error as Error).message}`);
throw new Error(`Failed to load hook trust: ${(error as Error).message}`, {
cause: error,
});
}
}

Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/config/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function readJson(path: string): Promise<DeepCodeSettings | undefined> {
} catch (err) {
const code = (err as NodeJS.ErrnoException).code;
if (code === 'ENOENT') return undefined;
throw new Error(`Failed to parse ${path}: ${(err as Error).message}`);
throw new Error(`Failed to parse ${path}: ${(err as Error).message}`, { cause: err });
}
}

Expand All @@ -104,7 +104,9 @@ async function readJsonRequired(path: string): Promise<DeepCodeSettings> {
const raw = await fs.readFile(path, 'utf8');
return parseSettings(raw, path);
} catch (err) {
throw new Error(`--settings: cannot load ${path}: ${(err as Error).message}`);
throw new Error(`--settings: cannot load ${path}: ${(err as Error).message}`, {
cause: err,
});
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/config/trust-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export class DirectoryTrustStore {
return validateState(parsed);
} catch (error) {
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return { dirs: {} };
throw new Error(`Failed to load directory trust: ${(error as Error).message}`);
throw new Error(`Failed to load directory trust: ${(error as Error).message}`, {
cause: error,
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/mcp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ async function resolveAuthHeaders(config: McpServerConfig): Promise<Record<strin
});
Object.assign(headers, parseHelperOutput(stdout));
} catch (err) {
throw new Error(`headersHelper failed: ${(err as Error).message}`);
throw new Error(`headersHelper failed: ${(err as Error).message}`, { cause: err });
}
}
return headers;
Expand Down
7 changes: 3 additions & 4 deletions packages/core/src/sandbox/dns-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ export function parseQName(buf: Buffer): string | null {
while (pos < buf.length) {
const len = buf[pos];
if (len === undefined) return null;
if (len === 0) {
pos++;
break;
}
// The root label ends the name. `pos` is not read after the loop, so
// there is nothing left to consume it for.
if (len === 0) break;
if (len > 63) return null; // compression / invalid
pos++;
if (pos + len > buf.length) return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tools/grep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const GrepTool: ToolHandler = {

args.push('--', input.pattern, searchPath);

let stdout = '';
let stdout: string;
try {
const result = await execFileAsync('rg', args, {
cwd: ctx.cwd,
Expand Down
19 changes: 13 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading