Refuse a query string on every route

Breaking: every route now answers a request with a query string with
400 invalid_query, where all but the module routes used to ignore it. A
caller must drop the query string and send any input in the JSON body.

No route takes an input from the query any more, now that the module
routes take copies and printer in the JSON body. The other routes
ignored a query, so a caller that sent one had it dropped without a
word: an old module caller's ?copies=2 on another route, or a typo.

The refusal's message is "query parameters are not accepted". The check
runs after routing and, under /api/v1, after the token, the rate limit
and the token's scope, so an unknown route still answers 404 and a token
sent only in the query still 401. A bare question mark is no query. The
OpenAPI document lists invalid_query on every route, and a route's
parameters can no longer be in the query.

Nothing that ships with the daemon sends it a query: the install, the
Docker image and the ntfy recipes post bodies or read /healthz plainly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-12-01 22:29:02 -06:00
1 parent 9e829bfce7
commit 6bfaee0bc8
8 files changed
+212 -33

No files matched your search

+6 -3
View File
@@ -29,6 +29,11 @@ tokens with `uberbringer token`. Tokens created by the old install script keep
working as long as the secret is unchanged. Tokens in query strings are not
accepted, because they leak into proxy logs.
No route takes a query string: every input goes in the JSON body, and the
path holds only a resource's ID or a fixed word. A request with a query
string gets `400` `invalid_query`. Under `/api/v1` the token and its scope
are checked first, so a token sent only in the query still gets `401`.
Keep a token off command lines too, where other users of the machine can
read it. The examples here send the header from a file only you can read,
which curl 7.55 and later take as `-H @file`;
@@ -302,7 +307,7 @@ Errors are JSON:
|--------|--------|---------|
| 400 | `invalid_job` | Malformed JSON, an unknown field, trailing data after the job, or invalid elements. When elements are invalid, `details` lists every problem. A `{"data": [...]}` body gets a message pointing to the [element format](#elements) |
| 400 | `invalid_payload` | A [module](#modules) route's body or payload that is not a JSON object, has an unknown field or a field of the wrong type, or is invalid, e.g. `invalid payload for module "note"`, or a body whose `copies` is outside 1–5. `details` lists every problem |
| 400 | `invalid_query` | On a module route: the request has a query string. Every input goes in the JSON body |
| 400 | `invalid_query` | The request has a query string, on any route. Every input goes in the JSON body |
| 400 | `unknown_printer` | On a module route: `printer` names a printer other than `default` |
| 400 | `bad_request` | A malformed HTTP request, refused by the server itself |
| 401 | `unauthorized` | `missing bearer token`, or `invalid or expired token`. Sent with `WWW-Authenticate` |
@@ -658,8 +663,6 @@ job and a `Location` header, or `503` when the queue is full or closing.
ntfy's messages as they are and ignores the fields it does not know.
- `400` `unknown_printer` means `printer` names a printer other than
`default`.
- `400` `invalid_query` means the request has a query string: every input
goes in the body.
- `404` `module_not_found` names an unknown module.
- `422` `module_failed` means the module built a receipt that fails
validation. That is a bug in the module, and it is logged.
+6 -4
View File
@@ -506,10 +506,12 @@ client ─HTTPS─▶ Caddy ─▶ server ── validate ──▶ printqueue (
the request's JSON body, never in a query parameter. The path holds only
a resource's ID, or a fixed word that names the route, as `last`,
`failed` and `uncertain` do in `/jobs/.../reprint`. A `GET` takes no
inputs beyond its path. The module routes follow it: their body holds
the module's payload, `copies` and `printer`, and a query string gets
`400` `invalid_query`. Some of the plans break the rule today, and a
later change makes them follow:
inputs beyond its path. Every route answers a query string with `400`
`invalid_query`, after the token and its scope under `/api/v1`, so a
caller that still sends one learns so instead of having it ignored. The
module routes' body holds the module's payload, `copies` and `printer`.
Some of the plans break the rule today, and a later change makes them
follow:
- the `?printer=` that docs/plans/printers.md puts on `/print`,
`/preview` and the module routes;
- the filters and paging that docs/plans/job-store.md's phase 2 puts in
+90 -10
View File
@@ -819,6 +819,19 @@
},
"description": "The running build"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Bad Request. invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_query"
]
},
"500": {
"content": {
"application/json": {
@@ -866,6 +879,19 @@
},
"description": "The job's status"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Bad Request. invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_query"
]
},
"401": {
"content": {
"application/json": {
@@ -962,6 +988,19 @@
},
"description": "The modules"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Bad Request. invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_query"
]
},
"401": {
"content": {
"application/json": {
@@ -1068,9 +1107,10 @@
}
}
},
"description": "Bad Request. invalid_job: invalid job.",
"description": "Bad Request. invalid_job: invalid job; invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_job"
"invalid_job",
"invalid_query"
]
},
"401": {
@@ -1232,11 +1272,11 @@
}
}
},
"description": "Bad Request. invalid_payload: invalid payload; invalid_query: query parameters are not accepted; unknown_printer: unknown printer.",
"description": "Bad Request. invalid_payload: invalid payload; unknown_printer: unknown printer; invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_payload",
"invalid_query",
"unknown_printer"
"unknown_printer",
"invalid_query"
]
},
"401": {
@@ -1401,9 +1441,10 @@
}
}
},
"description": "Bad Request. invalid_job: invalid job.",
"description": "Bad Request. invalid_job: invalid job; invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_job"
"invalid_job",
"invalid_query"
]
},
"401": {
@@ -1578,11 +1619,11 @@
}
}
},
"description": "Bad Request. invalid_payload: invalid payload; invalid_query: query parameters are not accepted; unknown_printer: unknown printer.",
"description": "Bad Request. invalid_payload: invalid payload; unknown_printer: unknown printer; invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_payload",
"invalid_query",
"unknown_printer"
"unknown_printer",
"invalid_query"
]
},
"401": {
@@ -1743,6 +1784,19 @@
},
"description": "The printer is reachable and ready, or does not report status"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Bad Request. invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_query"
]
},
"500": {
"content": {
"application/json": {
@@ -1789,6 +1843,19 @@
},
"description": "The document"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Bad Request. invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_query"
]
},
"500": {
"content": {
"application/json": {
@@ -1824,6 +1891,19 @@
},
"description": "A robots.txt that allows everything"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Bad Request. invalid_query: query parameters are not accepted.",
"x-uberbringer-codes": [
"invalid_query"
]
},
"500": {
"content": {
"application/json": {