fix(core): include underlying reason in ripgrep execution failures

This commit is contained in:
Christiaan Arnoldus
2026-07-30 11:35:32 +02:00
parent f0d2c8ffc8
commit d7f8da917e
3 changed files with 26 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---
Include the underlying reason in search execution failures instead of showing a bare "ripgrep execution failed" message.
+7 -5
View File
@@ -165,11 +165,13 @@ export const layer = Layer.effect(
)
const abortable = input.signal ? program.pipe(Effect.raceFirst(waitForAbort(input.signal))) : program
return abortable.pipe(
Effect.mapError((cause) =>
cause instanceof Error || cause instanceof InvalidPatternError
? cause
: failure("ripgrep execution failed", cause),
),
// kilocode_change start - surface the underlying reason instead of a bare wrapper message
Effect.mapError((cause) => {
if (cause instanceof Error || cause instanceof InvalidPatternError) return cause
const detail = cause instanceof globalThis.Error && cause.message.trim() ? `: ${cause.message.trim()}` : ""
return failure(`ripgrep execution failed${detail}`, cause)
}),
// kilocode_change end
)
}
+14
View File
@@ -61,4 +61,18 @@ describe("Ripgrep", () => {
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
),
)
// kilocode_change start - surfaced error keeps the underlying reason
it.live("includes the underlying reason in execution failures", () =>
Effect.gen(function* () {
const ripgrep = yield* Ripgrep.Service
const controller = new AbortController()
controller.abort()
const error = yield* ripgrep
.find({ cwd: process.cwd(), pattern: "*", limit: 1, signal: controller.signal })
.pipe(Effect.flip)
expect(error.message).toMatch(/^ripgrep execution failed: .+/)
}),
)
// kilocode_change end
})