Reference

Errors

Each validation and request error has a code you can look up.

Charter returns a machine-readable code on every failure so clients and scripts can branch without parsing free text. The shape differs by interface. Don't worry if you hit an error while exploring: the codes below map each failure to a stable name you may handle in code.

REST#

Failed HTTP calls return a JSON:API-style document:

{
  "errors": [
    {
      "status": "404",
      "code": "not_found",
      "title": "Not Found",
      "detail": "No posts record matched that id"
    }
  ]
}

Common document-level codes (from the shared vocabulary in the runtime):

Code Meaning
not_found No matching record, resource or route
unauthenticated No usable credential
forbidden Authenticated but not allowed
validation_error One or more input rules failed (field errors carry their own codes)
conflict Unique constraint already holds the value
missing_field A required value was absent
type_mismatch data.type disagrees with the path resource
bad_request Malformed request with no single field to blame
invalid_json Body is not parseable JSON
rate_limited Brute-force protection; check Retry-After
invalid_query_param Unknown or illegal query parameter
field_not_sortable _sort named a non-sortable field
field_not_searchable A text-search operator on a non-searchable field

List and write validation can return several errors in one response so the client sees the full set.

CLI#

CLI failures print to stderr (never stdout), including under --json. The human form is:

error[db.connect_failed]: could not reach the database at localhost:5432/charter
  connection refused (os error 61)

  next steps:
    1. Check the database is running and accepting connections.
    2. Check DATABASE_URL names the right host, port and database.
    3. Run `charter health` to test the connection on its own.

--json emits one object with code, summary, detail, fields, next_steps and exit_code. Exit codes classify the failure (usage, not found, conflict, config, and so on).

The full CLI catalog lives in the repository guide docs/cli-errors.md (every Code variant has a row there). Common prefixes: args.*, config.*, db.*.

MCP#

Model Context Protocol (MCP) tools report failures as JSON-RPC errors. Invalid arguments typically use the invalid-params code; unexpected server failures use the internal-error code. Record permission and claim-filter behavior still follow the same roles as REST; see MCP and Roles and permissions.