Conversation
computerRoutes()'s error handler mapped every thrown error to HTTP 400, including domain/service-state failures that are not the client's fault: an unconfigured computer service, an unknown Dot id, a disabled permission, or the computer supervisor being unreachable all came back as 400 Bad Request. That misclassifies retryable/server-side failures as client input errors and is inconsistent with workspace-routes.ts's existing convention, which reserves 400 for actual validation problems (malformed JSON, Zod failures) and uses 503 for everything else. Also added the malformed-JSON carve-out workspace-routes.ts already has (SyntaxError from a bad request body was previously falling through to the generic case, which is still correctly 400 here, but only by coincidence of being the blanket default -- now it's explicit and covered by a regression test, matching the actions route's /dots/:id/ computer/actions endpoint which is the only one that parses JSON input beyond the route param). Covered by a new tests/computer-routes.test.ts (computer-routes.ts had no direct test coverage before this), exercising: malformed JSON (400), a Zod validation failure (400), an unconfigured service (503), and an unknown Dot id (503).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
computerRoutes()'sonErrorhandler mapped every thrown error to HTTP 400, including domain/service-state failures that aren't the client's fault: an unconfigured computer service, an unknown Dot id, a disabled permission, or the computer supervisor being unreachable all came back as400 Bad Request.This is inconsistent with
workspace-routes.ts's existing convention, which reserves 400 for actual validation problems (malformed JSON, Zod failures) and falls back to 503 for everything else (see itsonError, and the recent #11 fix for the same class of issue).computer-routes.tshad no direct test coverage before this PR, so the gap wasn't caught.Changes
src/server/computer-routes.ts: Zod validation errors and malformed-JSON (SyntaxError) still return 400; everything else (service-not-configured, Dot-not-found, permission-disabled, upstream computer-service failures, etc.) now returns 503, matching the conventionworkspace-routes.tsalready uses.tests/computer-routes.test.ts(new): covers malformed JSON (400), a Zod validation failure (400), an unconfigured service (503), and an unknown Dot id (503).Test plan
npm test— 164 tests passing (160 pre-existing + 4 new), no regressions.npm run lint— clean.npm run typecheck— clean.npm run check-format— clean on changed files.npm run build— succeeds.Assisted by Claude Code (Anthropic) during investigation and implementation; reviewed and tested by me before opening this PR.