From 99b2a3a1a56598ee05becc98c8a6137e2c42a7a6 Mon Sep 17 00:00:00 2001 From: mnovak Date: Sat, 7 Nov 2026 18:57:54 +0100 Subject: [PATCH] [docs] API: what errors may repeat, Idempotency-Key in progress and limits, where a minted URL is held --- docs/api.md | 14 ++++++++++---- docs/ui-api.md | 12 ++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/api.md b/docs/api.md index 017a7fd..0589e4c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -16,8 +16,11 @@ Everything below was run end to end on loopback against `--dev` with a real edge - **Host header.** Only `127.0.0.1:`, `localhost:`, `[::1]:` and the configured `allowed_hosts` are answered (DNS rebinding). A browser write (`Origin` or `Sec-Fetch-Site` present) also needs `X-Ianitor-UI: 1` (CSRF). -- **Bodies** are JSON, at most 64 KiB, with no unknown fields. Error messages never repeat a - value you sent. +- **Bodies** are JSON, at most 64 KiB, with no unknown fields. Errors about the request + itself (bad JSON, a wrong type, an odd field name, a path that is no hostname) never repeat + what you sent. Errors about a host can repeat its values (hostname, upstream, header name) + in `params` and `detail`, but never a URL's user name and password (shown as `…@`), a secret + value or a token. - **Errors** have one shape; `code` is stable, `message` is plain English, `field` points at the form field, `params` holds the values in the message, `detail` is the technical text: @@ -32,7 +35,9 @@ Everything below was run end to end on loopback against `--dev` with a real edge `202 {"apply": {...}}` at once; poll `GET /applies/{id}` (every second) until `state` is `kept`, `reverted`, `failed` or `needs_attention`. Applies run one at a time, in order; the others are `queued`. -- **`Idempotency-Key`** on a write: a retry with the same key gets the same apply back. +- **`Idempotency-Key`** on a write: a retry with the same key gets the same apply back. While + the first request with a key is still being handled, a retry gets `409 request.in_progress` + (retry after 1 s). Keys are held in memory for 24 h (at most 2,000; then `429`). - **`base_rev`** (from `GET /hosts/{h}` or the overview's `rev`): the change is refused with `409 change.conflict` only if the same host file changed since. @@ -194,7 +199,8 @@ curl -s -H "$H" -H 'Content-Type: application/json' -X POST "$API/hosts/wiki.dev "has_password": false, "url": "https://wiki.dev.test:18443/?share=ish1.…", "warning": null } ``` -The URL is shown once (control keeps no token). The first visit trades the token for a +The URL is shown once: control never stores the token on disk; only an `Idempotency-Key` +retry of this request gets the same answer again, from memory, for 24 h. The first visit trades the token for a path-scoped `HttpOnly; Secure; SameSite=Lax` cookie and redirects to the same URL without it: ```sh diff --git a/docs/ui-api.md b/docs/ui-api.md index 7c09afa..df49d2e 100644 --- a/docs/ui-api.md +++ b/docs/ui-api.md @@ -495,8 +495,16 @@ written above. - Health: one admin Unix socket (mode 0660) carries both the read-only `GET /v1/status` and control's reload/trial calls, instead of a separate read-only socket. Edge keeps the last 5 results per upstream; `health.since` is tracked by control and restarts with it. -- `Idempotency-Key`s are remembered in memory for 24 h; a control restart forgets them. +- `Idempotency-Key`s are remembered in memory for 24 h; a control restart forgets them. A + retry while the first request is still running gets `409 request.in_progress`; with 2,000 + keys held, a new key gets `429 rate.limited`. +- Share links: at most 2,000 active links (`409 share.too_many`). A token in `?share=` on a + host without share links is removed before the request goes on. +- Wrong share passwords are also limited to 20 a minute per visitor network, whatever the + link; when the throttle's table is full, new visitors wait a minute rather than anyone's + count being forgotten. - Extra error codes: `change.unchanged`, `host.hostname.mismatch`, `host.upstream.host_name`, `request.*`, `repo.unexpected_file`, `repo.no_remote`, `share.unavailable`, - `share.not_found`, `share.replaces`, `share.password_long`, `token.not_found`, `token.name`, + `share.not_found`, `share.replaces`, `share.password_long`, `share.too_many`, + `request.in_progress`, `control.files_unwritten`, `token.not_found`, `token.name`, `token.expiry`, `file.*`, `site.*` (problems in `ianitor.toml`).