Repository navigation
fix: server error paths that still answered an empty 500 or lost the message - #1848
ralphstodomingo wants to merge 3 commits into
Conversation
…message - An unknown /api path answers the fixed body and a ref, recorded in opencode.log, not printed. - Forwarded HttpApi routes answer an unavailable remote config 502. - prompt_async's session.error carries a NamedError's text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BXxzvt5gnJKUdaiAK5SupM
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
@codex review against the numbered claims and the disclosed residuals in this PR's description: report only a reproducible trace that violates a numbered claim, or a defect the residuals don't disclose. Name the claim, the input, and the line. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Checking only for the ref let the middleware print the error without it. The test now also checks the log line names `HttpClientError` and that nothing printed does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BXxzvt5gnJKUdaiAK5SupM
|
@codex review against the numbered claims and the disclosed residuals in this PR's description: report only a reproducible trace that violates a numbered claim, or a defect the residuals don't disclose. Name the claim, the input, and the line. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Bun's `console.info` and `console.debug` don't go through `process.stdout.write`, so the checks missed them. The helper now spies every console method, records objects as Bun prints them and decodes byte chunks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BXxzvt5gnJKUdaiAK5SupM
|
@codex review against the numbered claims and the disclosed residuals in this PR's description: report only a reproducible trace that violates a numbered claim, or a defect the residuals don't disclose. Name the claim, the input, and the line. |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Review log: claims contractCodex rounds on this PR are scoped to these claims and residuals. Claims
Residuals
Rounds
|
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (3 files)
Notes:
Reviewed by deepseek-v4.1-flash-1017 · Input: 84.2K · Output: 45.4K · Cached: 3.7M Review guidance: REVIEW.md from base branch |
|
@codex review against the numbered claims and the disclosed residuals in the review-log comment on this PR: report only a reproducible trace that violates a numbered claim. Instances of the disclosed residuals are not findings. A round with no claim violation ends review. Look in particular at what cubic flagged on this head: which cause reason the HttpApi error middleware answers and records ( |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
hkaltai
left a comment
There was a problem hiding this comment.
Peer review (Claude + Codex + lead, one convergence round): no critical or major issues — approving. Four minor comments inline.
Nits (consolidated)
middleware/error.ts:9— the header comment still says the boundary "only replaces defect-only empty 500s"; it now also answers undeclared failures.middleware/error.ts:45,54— the ref format and the fixed message are rebuilt inline; this file now imports from@/altimate/server/error-response, soerrorRef()/unknownErrorBody(ref)would keep the Hono and HttpApi bodies from drifting.printedDuringis added here and an identical copy lands in #1849's new test file; consider a shared helper undertest/server/once both merge.sessionErrorreturns the event's properties, not the error —waitForSessionErrorEventwould read better.
🤖 Generated with Claude Code
| for (const line of buffered.split("\n")) { | ||
| if (!line.startsWith("data: ")) continue | ||
| const event = JSON.parse(line.slice("data: ".length)) |
There was a problem hiding this comment.
Minor — flaky SSE parsing
for (const line of buffered.split("\n")) {
if (!line.startsWith("data: ")) continue
const event = JSON.parse(line.slice("data: ".length))This loop also parses the trailing fragment after the last \n. When an SSE chunk is split mid-event and that fragment starts with data: , JSON.parse throws and the test fails intermittently. Split off the remainder first and only parse complete lines, e.g. const lines = buffered.split("\n"); buffered = lines.pop() ?? ""; for (const line of lines) ….
| } | ||
|
|
||
| test("an /api path no route serves answers the fixed message and a ref, recorded only in opencode.log", async () => { | ||
| // /api/config is not an /api route: it falls through to the web UI proxy, whose fetch fails. |
There was a problem hiding this comment.
Minor — network-dependent test
// /api/config is not an /api route: it falls through to the web UI proxy, whose fetch fails.This only passes while the hosted UI upstream (UI_UPSTREAM in src/server/shared/ui.ts) fails to resolve/connect. If that host comes up, or a resolver/proxy answers for it, the proxy forwards its status and the test fails; in a build with an embedded UI the path isn't exercised at all, and DNS timing can eat the timeout. Please make the failure deterministic — inject a failing HttpClient layer or point the upstream at a closed loopback port (the httpapi-ui.test.ts fixtures already do client injection), or add a direct errorLayer unit test with a route that fails with HttpClientError.
| return Effect.logError("failed", { ref, error, cause: Cause.pretty(cause) }).pipe( | ||
| // altimate_change start — recorded under the ref in opencode.log, as the Hono handlers do: the default logger | ||
| // here prints to the console, which the in-process TUI owns, and leaves the ref in no file | ||
| return Effect.promise(() => recordUnknownError("httpapi", ref, error)).pipe( |
There was a problem hiding this comment.
Minor — log record loses the rest of the cause
return Effect.promise(() => recordUnknownError("httpapi", ref, error)).pipe(The previous line logged Cause.pretty(cause) from the request fiber. Now only the one selected reason is recorded (wrapped as Cause.die(error) and run in a separate Effect.runPromise), so any other reasons in the cause (parallel failures, a finalizer error) and the fiber's spans/annotations are dropped, and a typed failure is logged as if it were a defect. Consider letting recordUnknownError take the full cause (optional param) and log Cause.pretty(cause); annotating the request method/path would also make a ref easier to trace back to a request.
| error: new NamedError.Unknown({ message: err instanceof Error ? err.message : String(err) }).toObject(), | ||
| // altimate_change start — as the HttpApi handler does: a NamedError's text from data.message (its own | ||
| // message is only its name), and no stack frames | ||
| error: new NamedError.Unknown({ message: clientMessage(err) }).toObject(), |
There was a problem hiding this comment.
Minor — some NamedErrors still publish only their name
error: new NamedError.Unknown({ message: clientMessage(err) }).toObject(),clientMessage only finds a NamedError's text in data.message. A NamedError whose data has no message — e.g. Provider.ModelNotFoundError ({ providerID, modelID, suggestions }) for an unknown model — still produces session.error with message: "ProviderModelNotFoundError", which is the symptom #1846 describes. The typed handler has the same gap, so this isn't a regression. Either publish the NamedError's own toObject() when it is one, or at least list this case under the PR's Limits (a generic summary of arbitrary data risks leaking fields, so a deliberate formatter is preferable to stringifying it).
Issue for this PR
Closes #1846
Type of change
What does this PR do?
Covers the server error paths #1788 didn't reach.
GET /api/config, falls through to the web UI proxy. The proxy's failed request reached the /api error middleware as a typed failure, and the middleware passed it on as an empty 500. The middleware now answers any undeclared failure the way it answers a defect: 500 with the fixed message and a ref, and the error recorded in opencode.log under that ref instead of printed. A declared error (an unknown session's 404) keeps its status and body./experimental/workspace) answers 502 when the remote config answers 500, with the same bodyGET /agentgives. /api routes themselves answer normally while it's down.session.errorevent like the typed handler: the NamedError's text (Agent not found: "no-such-agent". …), not just its name, and no stack frames.Limits:
write. A write throughBun.stdout/Bun.stderror straight to the file descriptors isn't seen.How did you verify your code works?
test/server/, 406 pass; one MCP status test fails here because it reads this machine's MCP config. Typecheck clean.Cost side effects
None.
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01BXxzvt5gnJKUdaiAK5SupM
Summary by CodeRabbit