Skip to content

docs(api): correct REST error status codes against v0.14.3 - #224

Open
TimeToBuildBob wants to merge 3 commits into
ActivityWatch:masterfrom
TimeToBuildBob:bob/docs-api-error-codes-v0143
Open

TimeToBuildBob wants to merge 3 commits into
ActivityWatch:masterfrom
TimeToBuildBob:bob/docs-api-error-codes-v0143

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

The REST reference's error-handling notes don't match the current release. I re-ran each claim against the v0.14.3 linux release (aw-server-rust 0.14.3 and the bundled Python aw-server), with isolated data dirs and both servers in normal (non-testing) mode.

Claim in api/rest.rst Observed on v0.14.3
aw-server-rust returns an HTML page for 400/422 JSON {"message": ...}, content-type: application/json
Python returns 500 for missing bucket fields 400 {"message": "Missing required field(s): type, hostname"}
Heartbeat without pulsetime: "HTML 422" on aw-server-rust 422, JSON body
aw-server-rust query errors return 500 400 for an undefined variable, a syntax error, or an unknown bucket (Python also returns 400)
Import "returns 400 for malformed input" 400 only for invalid JSON. Well-formed JSON of the wrong shape gives 422 on aw-server-rust (400 on Python). aw-server-rust also returns 422 for a multipart field not named buckets.json
Import into an existing bucket: Python returns 500 400 Bucket 'b1' already exists ...
API playground at /api/ Served by Python aw-server only; aw-server-rust returns 404

Repro, for one server (--port adapted, separate XDG_* dirs):

curl -s -w ' %{http_code}\n' -X POST -H Content-Type:application/json \
  -d '{"timeperiods":["2026-01-01T00:00:00Z/2026-01-02T00:00:00Z"],"query":["RETURN = nosuchvar;"]}' \
  http://127.0.0.1:$PORT/api/0/query/
# aw-server-rust: {"message":"VariableNotDefined(\"nosuchvar\")"} 400

Not changed here: the single-event GET line, which #213 already corrects. Also not changed: the ?force=1 requirement on bucket delete. The docs are right for the Python server (401 without it). aw-server-rust ignores the parameter and deletes anyway, and I'm filing that separately as a code issue.

Found during a docs-vs-reality pass over install, API, query and sync pages.

Every claim was re-run against the v0.14.3 release (aw-server-rust and
Python aw-server, non-testing mode):

- aw-server-rust error bodies are JSON {"message": ...}, not HTML
- Python returns 400 (not 500) for missing bucket fields and for
  importing into an existing bucket
- single-event GET for an unknown id is 404 on aw-server-rust too
- query errors are 400 on aw-server-rust, not 500
- import: 422 for well-formed wrong-shape JSON on aw-server-rust; its
  multipart field must be named buckets.json
- the /api/ playground is Python-only (aw-server-rust returns 404)

Git-Session-Id: bed1476c-0b54-4dde-9c03-8080d9dde1e7
Git-Session-Id: bed1476c-0b54-4dde-9c03-8080d9dde1e7
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Review guide (auto-posted)

Structured warm-up for reviewers — what changed, what to run, where to look.

Key files

  • src/api/rest.rst (+11/-10, Δ21)

Suggested verification

  • Run the repo's usual CI-equivalent checks locally

Known risks / watch points

  • No automatic high-risk tags; use file list + diff for judgment.

Suggested review focus

  • Confirm behavior matches the PR description acceptance criteria.
  • Skim the largest diffs first (listed above).
  • If CI is green, spot-check the highest-risk paths called out here.

Generated by scripts/github/pr-warmup-review-guide.py for #224.

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The changes affect readers of one API reference page, not server behavior.

Safe to merge; the remaining issues are limited to wording about error responses.

Findings

  1. P2 JSON error promise is broad ▶
  2. P2 Upload status is missing ▶

Summary

Updates the REST reference using the author's v0.14.3 release checks.

  • The REST reference says the API browser is available only on Python aw-server.
  • The REST reference updates the error responses listed for common API requests.
  • The REST reference spells out how each server responds to import requests.

Reviews (1) · Last reviewed commit: "docs(api): leave the single-event GET li..." · Reviewed by Greptile

Comment thread src/api/rest.rst Resolved
Comment thread src/api/rest.rst Resolved
…load field

Git-Session-Id: bed1476c-0b54-4dde-9c03-8080d9dde1e7
@TimeToBuildBob

TimeToBuildBob commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

Documentation-only PR that updates error status codes and error-body claims in src/api/rest.rst, which the author says were re-checked against the v0.14.3 release. It replaces the note saying aw-server-rust returns HTML for 400/422 with one saying both servers returned JSON with a message field. It changes the Python missing-field bucket-create code from 500 to 400, and the query error codes to 400 on both servers. It also splits import errors into invalid-JSON, wrong-shape and multipart-field cases, changes the Python existing-bucket import failure to 400, and notes that the API browser at /api/ is served only by the Python aw-server.

Safe to merge — no P0/P1 findings

Confidence 5/5

✅ No thread-worthy findings. Advisory notes follow; they are retained without opening review threads.

1 advisory finding (summary-only, not scored)

These P2 guard, heuristic, trade-off, or documentation claims are retained for judgment without opening review threads.

⚠️ P2 medium — src/api/rest.rst:222

The PR re-verifies the existing-bucket import behaviour against v0.14.3 and rewrites the Python half of this sentence to 400 (Bucket '<id>' already exists). It leaves the aw-server-rust half qualified as (master). Elsewhere the reference now presents its error claims as observed on v0.14.3, for example line 46 ("In v0.14.3, the errors checked for this reference…"). A reader on the v0.14.3 Tauri app therefore cannot tell what their aw-server-rust does when importing into an existing bucket: merge, reject, or something else. The PR description's table does not list a v0.14.3 aw-server-rust result for this case either. A client author who relies on the documented merge behaviour could re-import an export into a live v0.14.3 aw-server-rust instance and get an unexpected error or duplicated events. The line should state the observed v0.14.3 aw-server-rust result, or say explicitly that the merge applies only to unreleased master.

How this was verified: Compared line 222 with the v0.14.3 framing on line 46 and with the PR description's table. The table's 'Import into an existing bucket' row reports only the Python result (400 Bucket 'b1' already exists), not an aw-server-rust v0.14.3 result.

Consensus: 2/3 passes agreed — pass 2 looked and disagreed

Files changed (1) — the diff as I read it
  • src/api/rest.rst — Rewrites the error-body note and the API browser/playground notes, and changes the documented status codes for bucket create, heartbeat without pulsetime, query errors and /api/0/import, including the existing-bucket import case.

Reviewed 1601b8fdb13e · panel: claude-code:claude-opus-5-5 + codex:gpt-6.1-sol + claude-code:claude-opus-5-5#2 · subscription engine · 21s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

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