Skip to content

fix(kiloclaw): attach status 404 to 'Instance not provisioned' errors#1388

Merged
jeanduplessis merged 2 commits intomainfrom
kiloclaw-correct-api-response
Mar 23, 2026
Merged

fix(kiloclaw): attach status 404 to 'Instance not provisioned' errors#1388
jeanduplessis merged 2 commits intomainfrom
kiloclaw-correct-api-response

Conversation

@jeanduplessis
Copy link
Contributor

Summary

Problem

The start, stop, and destroy methods on KiloClawInstance threw plain Error objects when called on instances that were never provisioned. API route handlers that inspect error.status to determine HTTP response codes could not distinguish "not found" from internal errors, resulting in 500 responses instead of 404.

Solution

  • Attach { status: 404 } to all three "Instance not provisioned" error throws via Object.assign in start(), stop(), and destroy().
  • Add test coverage for each method confirming the error carries status: 404.

Why this approach

Object.assign on the thrown Error is the lightest change that gives callers a machine-readable status without introducing a custom error class. A custom HttpError subclass was considered but would be overkill for a single status code used in three places.

Verification

  • pnpm typecheck — passed (all packages)
  • pnpm test --run (kiloclaw) — 951 tests passed, 0 failed
  • pnpm format — no remaining formatting issues
  • pnpm lint — passed (pre-push hook)

Visual Changes

N/A

Reviewer Notes

  • The three throw sites are in kiloclaw/src/durable-objects/kiloclaw-instance/index.ts at the entry guards of start() (line 693), stop() (line 947), and destroy() (line 994).
  • Callers that already catch these errors and check .status will now get 404 instead of undefined. Callers that don't inspect .status are unaffected.

The start, stop, and destroy methods threw plain Error objects when
called on unprovisioned instances. Callers that inspect error.status
(e.g. API route handlers) could not distinguish 'not found' from
internal errors, returning 500 instead of 404.
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 23, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • kiloclaw/src/durable-objects/kiloclaw-instance/index.ts

Reviewed by gpt-5.4-20260305 · 224,501 tokens

@jeanduplessis jeanduplessis merged commit 9790a2e into main Mar 23, 2026
18 checks passed
@jeanduplessis jeanduplessis deleted the kiloclaw-correct-api-response branch March 23, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants