mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-05 07:25:08 +00:00
docs: give each dl and serve flag and the error envelope one owner page and tighten the cli-reference test
This commit is contained in:
@@ -18,9 +18,7 @@ Start the server with [`unshackle serve`](../../guide/cli-reference.md). By defa
|
||||
- **Compression.** JSON responses of 256 bytes or more are gzip-compressed when the client sends `Accept-Encoding: gzip`. A [slow response](remote-sessions.md#slow-responses) is not compressed.
|
||||
- **Service allowlist.** The effective allowlist for your API key filters the service-facing endpoints (the intersection of the global `serve.services` list and your per-key list). The server treats services you cannot use as unknown.
|
||||
- **Remote services.** A full-mode server can run a service through one of its own `remote_services` servers. See [Remote services relay](#remote-services-relay).
|
||||
|
||||
!!! warning "Error responses have two shapes"
|
||||
Structured application errors (raised inside a handler) return `{"status": "error", "error_code": "...", "message": "...", "timestamp": "..."}`. The authentication middleware, however, returns a **different** shape: `{"status": 401, "message": "..."}` with an integer `status` and no `error_code`. The same middleware answers `429` in that shape when an API key goes over its rate limit. Clients must accept both shapes. The [Error responses](#error-responses) section at the bottom of this page gives the full error model.
|
||||
- **Errors.** [Error Responses](errors.md) gives the [standard error shape](errors.md#the-standard-error-shape) and the [authentication error](errors.md#the-authentication-error-exception) of the API-key middleware.
|
||||
|
||||
---
|
||||
|
||||
@@ -439,7 +437,7 @@ Make a download job. It requires `service` and `title_id`. Every other field is
|
||||
|
||||
<!-- download-fields -->
|
||||
|
||||
**Validation.** Invalid values return `400 INVALID_PARAMETERS`. `vcodec`, `acodec` and `sub_format` take the same spellings as the CLI options of the same name (`unshackle dl --help` prints each list). The API and the CLI read one list, so they cannot disagree. `range` must be one of SDR/HDR10/HDR10P/VIVID/DV/HLG/HYBRID, and `HDR10+` and `HDR Vivid` are also valid. The bitrate, download worker, and download counts must be positive integers. You cannot combine `no_subs` with `subs_only`, or `no_audio` with `audio_only`. The server runs the same option checks as `unshackle dl`, so a request that `dl` would refuse returns `400` when you submit it, and the message names the `dl` option. The language fields (`lang`, `v_lang`, `a_lang`, `s_lang`, `forced_s_lang` and the `require_*` fields) must be arrays of strings: a single string such as `"en"` returns `400`. The server checks every other field with the type of its `dl` option. A `null` or an empty string gets the default from the table.
|
||||
**Validation.** Invalid values return `400 INVALID_PARAMETERS`. `vcodec`, `acodec` and `sub_format` take the same spellings as the CLI options of the same name (`unshackle dl --help` prints each list). The API and the CLI read one list, so they cannot disagree. You cannot combine `no_subs` with `subs_only`, or `no_audio` with `audio_only`. The server runs the same option checks as `unshackle dl`, so a request that `dl` would refuse returns `400` when you submit it, and the message names the `dl` option. The language fields (`lang`, `v_lang`, `a_lang`, `s_lang`, `forced_s_lang` and the `require_*` fields) must be arrays of strings: a single string such as `"en"` returns `400`. The server checks every other field with the type of its `dl` option. A `null` or an empty string gets the default from the table.
|
||||
|
||||
**Service options.** A service's own CLI options travel in the same body. Send them in a nested
|
||||
`service_params` object, or as flat top-level keys. When the body has `service_params`, the server
|
||||
@@ -981,37 +979,6 @@ Answer the prompt of a remote login. Body: `{ "response": "..." }` (required).
|
||||
|
||||
---
|
||||
|
||||
## Error responses
|
||||
|
||||
The server serialises every structured error raised inside a handler to the same JSON envelope:
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "error",
|
||||
"error_code": "INVALID_PARAMETERS",
|
||||
"message": "Invalid video codec: XYZ",
|
||||
"timestamp": "2026-07-03T12:00:00+00:00",
|
||||
"details": { "field": "vcodec" },
|
||||
"retryable": true,
|
||||
"debug_info": { "exception_type": "APIError", "traceback": "..." }
|
||||
}
|
||||
```
|
||||
|
||||
- `details` appears only when non-empty.
|
||||
- `retryable` appears only when the error is retryable (e.g. network errors, rate limiting).
|
||||
- `debug_info` appears only when you start the server with `--debug-api`.
|
||||
|
||||
!!! warning "Authentication errors differ"
|
||||
Errors raised by the API-key middleware use a distinct shape (`{"status": 401, "message": "Secret Key is Empty."}`, `{"status": 401, "message": "Secret Key is Invalid."}`, or `{"status": 429, "message": "Rate limit exceeded."}` with a `Retry-After` header) with an integer `status` and no `error_code`, `timestamp`, or `details`. A `429` from the middleware therefore carries no `error_code`, unlike the `RATE_LIMITED` code below, which a handler raises for a rate limit the *service* imposed. A malformed JSON body on any POST, by contrast, returns the standard envelope with `error_code: "INVALID_INPUT"`.
|
||||
|
||||
### Error codes and default status
|
||||
|
||||
The [error code catalogue](errors.md#error-code-catalogue) gives the default HTTP status of each error code.
|
||||
|
||||
When a generic (uncategorised) exception reaches a handler, unshackle inspects its message and type to pick a code. For example, messages mentioning "connection" or "timeout" become `NETWORK_ERROR` (424, retryable), "rate limit" or "429" become `RATE_LIMITED` (429, retryable), and anything unrecognised collapses to `INTERNAL_ERROR` (422).
|
||||
|
||||
---
|
||||
|
||||
## See also
|
||||
|
||||
- [Server Overview](index.md). What the server is and when to use it.
|
||||
|
||||
Reference in New Issue
Block a user