From 003049b2bb8626a3859a2083eb1d2524e0849b15 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 24 Nov 2026 11:06:35 +0000 Subject: [PATCH 1/3] docs(api): correct REST error status codes against v0.14.3 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 --- src/api/rest.rst | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/api/rest.rst b/src/api/rest.rst index 6225093..49c3d8e 100644 --- a/src/api/rest.rst +++ b/src/api/rest.rst @@ -15,7 +15,7 @@ event access. .. note:: Part of the documentation might be outdated, you can get up-to-date API documentation - in the API browser available from the web UI of your aw-server instance. + in the API browser available from the web UI of the Python aw-server (aw-server-rust does not serve it). .. contents:: @@ -34,7 +34,7 @@ REST Reference -------------- .. note:: - This reference covers the endpoints watchers and clients use most. For an interactive view of the API, try out the API playground running on your local server at: http://localhost:5600/api/ + This reference covers the endpoints watchers and clients use most. For an interactive view of the API, try out the API playground running on your local server at: http://localhost:5600/api/ (Python aw-server only; aw-server-rust returns ``404`` there) All endpoints live under ``/api/0/``. Request and response bodies are JSON unless noted. Timestamps must be RFC 3339 with a timezone (``2026-10-01T10:00:00Z``). @@ -43,8 +43,8 @@ Durations are in seconds. .. note:: There are two server implementations: ``aw-server`` (Python, the default in the classic app) and ``aw-server-rust`` (used by the Tauri app). They agree on the happy path but differ on error handling. Differences are called out below. - Do not rely on error response bodies: aw-server-rust returns an HTML page for 400/422 errors, - and some invalid inputs cause a 500 on the Python server. + Both return JSON error bodies with a ``message`` field, but the status codes and messages differ, + so do not rely on the exact error response. Server info ~~~~~~~~~~~ @@ -93,7 +93,7 @@ Body (all three fields are required): {"client": "aw-watcher-example", "type": "app.example", "hostname": "my-host"} Status codes: ``200`` created, ``304`` if the bucket already exists (the existing bucket is left unchanged), -``400`` for malformed JSON, ``422`` for missing fields (aw-server-rust; the Python server returns ``500``). +``400`` for malformed JSON, ``422`` for missing fields (aw-server-rust; the Python server returns ``400``). Delete ^^^^^^ @@ -158,7 +158,7 @@ Get / delete a single event GET /api/0/buckets//events/ DELETE /api/0/buckets//events/ -``GET`` returns ``404`` for an unknown id on the Python server but ``500`` on aw-server-rust. +``GET`` returns ``404`` for an unknown id. ``DELETE`` returns ``200`` even if no event with that id exists. Heartbeat API @@ -172,7 +172,7 @@ The `heartbeat ` API is one of the most useful endpoints for writing The ``pulsetime`` query parameter is **required** and must be a number: it is the maximum gap, in seconds, between two heartbeats with identical ``data`` for them to be merged into one event. -Requests without it are rejected (``400`` on the Python server, an HTML ``422`` on aw-server-rust). +Requests without it are rejected (``400`` on the Python server, ``422`` on aw-server-rust). Body: a single event object (not a list), with ``timestamp``, ``duration`` (usually ``0``) and ``data``: @@ -202,8 +202,8 @@ See `Writing Queries <./../examples/querying-data.html>`_ for the query language ``timeperiods`` is a list of ``start/end`` RFC 3339 intervals and ``query`` is a list of statements (a single string is rejected). The response is a list with one result per time period. -Status codes: ``200``, ``422`` for a malformed request body (aw-server-rust), ``400`` for a query that fails to parse (Python server). -aw-server-rust reports query errors (syntax errors, undefined variables, unknown buckets) as ``500`` with a JSON ``message``. +Status codes: ``200``, ``422`` for a malformed request body (aw-server-rust), +``400`` for query errors (syntax errors, undefined variables, unknown buckets) on both servers. Export and import ~~~~~~~~~~~~~~~~~ @@ -216,9 +216,10 @@ Export and import Per-bucket export returns ``{"buckets": {: {..., "events": [...]}}}``, or ``404`` for an unknown bucket. ``/api/0/import`` takes that same format (JSON body, or a multipart file upload as the web UI does) -and returns ``400`` for malformed input. +and returns ``400`` for invalid JSON. For well-formed JSON of the wrong shape, aw-server-rust returns ``422`` +and the Python server ``400``. On aw-server-rust, a multipart upload must name its file field ``buckets.json``. Importing into a bucket that already exists is not consistent between servers: aw-server-rust (master) merges -the events, while the Python server fails with ``500``. +the events, while the Python server rejects it with ``400`` (``Bucket '' already exists``). Settings API ~~~~~~~~~~~~ From 638797b76e893647c2d3c727e4a7fde78cefb7fe Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 24 Nov 2026 11:07:32 +0000 Subject: [PATCH 2/3] docs(api): leave the single-event GET line to #213 Git-Session-Id: bed1476c-0b54-4dde-9c03-8080d9dde1e7 --- src/api/rest.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/rest.rst b/src/api/rest.rst index 49c3d8e..f0ba3a0 100644 --- a/src/api/rest.rst +++ b/src/api/rest.rst @@ -158,7 +158,7 @@ Get / delete a single event GET /api/0/buckets//events/ DELETE /api/0/buckets//events/ -``GET`` returns ``404`` for an unknown id. +``GET`` returns ``404`` for an unknown id on the Python server but ``500`` on aw-server-rust. ``DELETE`` returns ``200`` even if no event with that id exists. Heartbeat API From 1601b8fdb13ea9e93d7777834a4c75ecf12b558b Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 24 Nov 2026 11:16:00 +0000 Subject: [PATCH 3/3] docs(api): scope the JSON-error note; state the 422 for a misnamed upload field Git-Session-Id: bed1476c-0b54-4dde-9c03-8080d9dde1e7 --- src/api/rest.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/rest.rst b/src/api/rest.rst index f0ba3a0..b2f4f2e 100644 --- a/src/api/rest.rst +++ b/src/api/rest.rst @@ -43,8 +43,9 @@ Durations are in seconds. .. note:: There are two server implementations: ``aw-server`` (Python, the default in the classic app) and ``aw-server-rust`` (used by the Tauri app). They agree on the happy path but differ on error handling. Differences are called out below. - Both return JSON error bodies with a ``message`` field, but the status codes and messages differ, - so do not rely on the exact error response. + In v0.14.3, the errors checked for this reference returned JSON with a ``message`` field on both servers, + but status codes and messages differ. Check the HTTP status first, and handle a body that is not JSON + or has no ``message``. Server info ~~~~~~~~~~~ @@ -217,7 +218,7 @@ Export and import Per-bucket export returns ``{"buckets": {: {..., "events": [...]}}}``, or ``404`` for an unknown bucket. ``/api/0/import`` takes that same format (JSON body, or a multipart file upload as the web UI does) and returns ``400`` for invalid JSON. For well-formed JSON of the wrong shape, aw-server-rust returns ``422`` -and the Python server ``400``. On aw-server-rust, a multipart upload must name its file field ``buckets.json``. +and the Python server ``400``. On aw-server-rust, a multipart upload returns ``422`` if its file field is not named ``buckets.json``. Importing into a bucket that already exists is not consistent between servers: aw-server-rust (master) merges the events, while the Python server rejects it with ``400`` (``Bucket '' already exists``).