Skip to content

refactor: classify errors once and add NotFound (#1517) - #1524

Merged
ajianaz merged 1 commit into
developfrom
refactor/classify-errors
Oct 22, 2026
Merged

ajianaz merged 1 commit into
developfrom
refactor/classify-errors

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

What

First item of the round-2 architecture deepening (#1523). Error gets a NotFound variant and Error::class() (BadRequest, NotFound, SecretDetected, Internal). The server answers by class through one core_error in context.rs, replacing seven hand-written Validation => 400, else 500 arms (PUT /memory update and namespace move, four room handlers, /consolidate/pair). The two handlers that matched contains("not found") (POST /doc/move, DELETE /room/delete) read the class instead; the core sites on those two paths (doc_move, delete_room) now return NotFound.

Why

Status policy lived in a dozen places and two of them depended on message text. No HTTP status changes: a missing memory on update and a missing room on rename are still 400 (they stay Validation, pinned by a test) until the contract with uteke-cloud decides to move them; that is the follow-up. The only visible difference is the text of the POST /doc/move 404, which no longer starts with Validation error: (also in the CLI and MCP text). Refs #1517.

Testing

  • clippy -D warnings, fmt, cargo test --workspace pass; cargo run -p docgen changes nothing
  • the new server tests (handlers/error_tests.rs) also pass on an unmodified develop worktree, which shows the statuses did not move
  • 4 core tests (class of every variant, bare NotFound text, the two paths, the 400 sites staying Validation) and 2 server tests
  • reviewed locally with the Cora MCP agent reviewer before pushing: no blocking finding; one minor note (a 500 body still carries the error message, as the replaced arms did) is documented in the code and left for a follow-up

@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 3b68942 into develop Oct 22, 2026
15 checks passed
@ajianaz
ajianaz deleted the refactor/classify-errors branch October 22, 2026 00:40
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.

1 participant