Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
docs: correct the API error-code table to the status vocabulary the server emits
Adam Eivyf947e8be24cf
diff --git a/docs/API.md b/docs/API.mdindex 8c0c92803e..812cc22376 100644--- a/docs/API.md+++ b/docs/API.md@@ -1014,11 +1014,27 @@ All errors return JSON with consistent structure:}```-Common error codes:-- `NOT_FOUND` - Resource not found-- `VALIDATION_ERROR` - Invalid request data-- `COMMAND_NOT_ALLOWED` - Shell command not in allowlist-- `INTERNAL_ERROR` - Server error+When a route throws without naming a `code`, it is derived from the HTTP status+(`ERROR_CODES_BY_STATUS` in `server/lib/errorHandler.js`, the same table the+agent-tool resource advertises):++| Status | Code | Meaning |+|--------|------|---------|+| 400 | `BAD_REQUEST` | Malformed request |+| 401 | `UNAUTHORIZED` | Authentication missing or rejected |+| 403 | `FORBIDDEN` | Refused, including a shell command outside the allowlist |+| 404 | `NOT_FOUND` | Resource not found |+| 409 | `CONFLICT` | State conflict (duplicate, stale, or already running) |+| 422 | `VALIDATION_ERROR` | Request understood but invalid |+| 500 | `INTERNAL_ERROR` | Server error (also the fallback for any unlisted status) |+| 502 | `BAD_GATEWAY` | An upstream service failed |+| 503 | `SERVICE_UNAVAILABLE` | A dependency is not available |++Zod request validation (`validateRequest`) answers `400` with+`VALIDATION_ERROR` and the field errors in `context.details`. Domain routes may+also set their own code (for example `MERGE_METHOD_NOT_ALLOWED`) on top of the+status — branch on the status first, and treat an unfamiliar `code` as a+refinement of it.### Catalog scrap graph commitsdiff --git a/docs/api-doc.test.js b/docs/api-doc.test.jsindex 652858bd87..8caa14a9ec 100644--- a/docs/api-doc.test.js+++ b/docs/api-doc.test.js@@ -28,6 +28,7 @@ import { dirname, join } from 'path';import { fileURLToPath } from 'url';import { describe, expect, it } from 'vitest';import { buildApiRouteCatalog } from '../server/lib/apiRouteGraph.js';+import { ERROR_CODES_BY_STATUS } from '../server/lib/errorHandler.js';const DOCS_DIR = dirname(fileURLToPath(import.meta.url));const DOC = readFileSync(join(DOCS_DIR, 'API.md'), 'utf8');@@ -118,4 +119,17 @@ describe('docs/API.md matches the mounted route graph', () => {});expect(uncovered, 'server/index.js mounts API prefixes docs/API.md never mentions — add a route-domain index row').toEqual([]);});++ it('documents the status-to-code vocabulary the error envelope actually emits', () => {+ // The table is a published contract (`apiToolResource.js` advertises the same+ // map). A code listed here that no route emits — `COMMAND_NOT_ALLOWED` was one;+ // a disallowed command answers 403 `FORBIDDEN` — sends a client branching on+ // a value it can never receive.+ const documented = Object.fromEntries(+ [...section('## Error Responses', '### Catalog scrap graph commits')+ .matchAll(/^\|\s*(\d{3})\s*\|\s*`([A-Z_]+)`/gm)]+ .map(([, status, code]) => [status, code]),+ );+ expect(documented).toEqual(ERROR_CODES_BY_STATUS);+ });});