[PR #4404] [CLOSED] fix(kuna): fall back to the retained cause when stderr is empty #6215

Closed
opened 2026-10-31 01:12:44 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4404
Author: @Lew1sWong
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: fix/kuna-empty-stderr-fallback


📝 Commits (1)

  • e528a36 fix(kuna): fall back to the retained cause when stderr is empty

📊 Changes

3 files changed (+27 additions, -1 deletions)

View changed files

📝 src/kuna/KunaCommand.ts (+2 -1)
📝 tests/boundary/providers/kuna/fakeKuna.ts (+3 -0)
📝 tests/boundary/providers/kuna/kunaProjectCache.test.ts (+22 -0)

📄 Description

Summary

Fixes #4374. When a Kuna command exits non-zero without writing to stderr, the user message now ends with the retained cause instead of nothing after the colon.

Problem and expected behavior

commandFailure in src/kuna/KunaCommand.ts takes the last stderr line with capturedOutput?.stderr.trim().split("\n").at(-1) ?? cause.message. For empty stderr, "".split("\n") is [""], so .at(-1) is "", not undefined, and ?? keeps the empty string.

  • Before: kuna decompile-project failed with exit code 1:
  • After: kuna decompile-project failed with exit code 1: Command failed; inspect its exit status and diagnostics.

Nonempty stderr behavior is unchanged: the last line is still reported.

Change and scope

Replace ?? with || so an empty last line also falls back to cause.message. A ternary was tried first but raised commandFailure above the lint complexity limit; || keeps the branch count unchanged. No other paths change.

Contribution scope: ordinary fix within existing boundaries; maintainer scope decision not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Kuna provider, commandFailure message construction.

  • Contribution scope fit and linked maintainer decision: not applicable (bug fix).

  • CLI and MCP/tool-catalog contract: none; only the userMessage text for empty-stderr failures changes.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: none.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none.

  • Documentation or usability only; no target interaction.

Evidence and regression coverage

  • Tests added or updated: new silent-exit-failure mode in the fake Kuna (tests/boundary/providers/kuna/fakeKuna.ts) and a regression test in kunaProjectCache.test.ts asserting the fallback message.
  • Base reproduction: on the unmodified base the new test fails with "kuna decompile-project failed with exit code 1: ", matching the issue.
  • Remaining proof gaps: verified with the fake Kuna only; a real Kuna binary was not run.

Validation performed

Node 24.18.0, macOS.

  • npx vitest run tests/boundary/providers/kuna (after npm run build) — 22 files, 236 tests passed
  • npm run typecheck — passed
  • npx oxlint and npx oxfmt --check on changed files — no new warnings, formatted
  • npm run check:changed — passed
  • Full npm run check:pr — not run

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none needed.

Author readiness

Human owner: @Lew1sWong

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4404 **Author:** [@Lew1sWong](https://github.com/Lew1sWong) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/kuna-empty-stderr-fallback` --- ### 📝 Commits (1) - [`e528a36`](https://github.com/morluto/rea/commit/e528a3619f24e38ed46e9c34297591b84f3a97d6) fix(kuna): fall back to the retained cause when stderr is empty ### 📊 Changes **3 files changed** (+27 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/kuna/KunaCommand.ts` (+2 -1) 📝 `tests/boundary/providers/kuna/fakeKuna.ts` (+3 -0) 📝 `tests/boundary/providers/kuna/kunaProjectCache.test.ts` (+22 -0) </details> ### 📄 Description ## Summary Fixes #4374. When a Kuna command exits non-zero without writing to stderr, the user message now ends with the retained cause instead of nothing after the colon. ## Problem and expected behavior `commandFailure` in `src/kuna/KunaCommand.ts` takes the last stderr line with `capturedOutput?.stderr.trim().split("\n").at(-1) ?? cause.message`. For empty stderr, `"".split("\n")` is `[""]`, so `.at(-1)` is `""`, not `undefined`, and `??` keeps the empty string. - Before: `kuna decompile-project failed with exit code 1: ` - After: `kuna decompile-project failed with exit code 1: Command failed; inspect its exit status and diagnostics.` Nonempty stderr behavior is unchanged: the last line is still reported. ## Change and scope Replace `??` with `||` so an empty last line also falls back to `cause.message`. A ternary was tried first but raised `commandFailure` above the lint complexity limit; `||` keeps the branch count unchanged. No other paths change. Contribution scope: ordinary fix within existing boundaries; maintainer scope decision not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: Kuna provider, `commandFailure` message construction. - Contribution scope fit and linked maintainer decision: not applicable (bug fix). - CLI and MCP/tool-catalog contract: none; only the `userMessage` text for empty-stderr failures changes. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: not applicable. - Generated metadata, package, or installation impact: none. - [x] Documentation or usability only; no target interaction. ## Evidence and regression coverage - Tests added or updated: new `silent-exit-failure` mode in the fake Kuna (`tests/boundary/providers/kuna/fakeKuna.ts`) and a regression test in `kunaProjectCache.test.ts` asserting the fallback message. - Base reproduction: on the unmodified base the new test fails with `"kuna decompile-project failed with exit code 1: "`, matching the issue. - Remaining proof gaps: verified with the fake Kuna only; a real Kuna binary was not run. ## Validation performed Node 24.18.0, macOS. - `npx vitest run tests/boundary/providers/kuna` (after `npm run build`) — 22 files, 236 tests passed - `npm run typecheck` — passed - `npx oxlint` and `npx oxfmt --check` on changed files — no new warnings, formatted - `npm run check:changed` — passed - Full `npm run check:pr` — not run ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: not applicable. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none needed. ## Author readiness Human owner: @Lew1sWong - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:12:44 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6215
No description provided.