Repository navigation
docs(sdk): /health answers nine keys with idle unloading on, and the gate could not see them - #1143
Conversation
…page says so The AST gate read only the return dict's own literal keys, so the two conditional fields spread by `**idle` were invisible and docs/typescript-sdk.md under-reported the shape while cross-referencing the page that documents them. Resolve a starred spread to the dict it unpacks, keep the sentence pinned, and name the liveness-only arm the client accepts.
|
Merged. The gate was the bug, not the page.
The anonymous-probe half is worth having on the SDK page too: on a deployment with |
What
Two halves of the same claim, both wrong, both about the fields
/healthanswers:docs/typescript-sdk.mdtold a reader thatlaya-serveanswers seven keys and cross-referenceddocs/http-api.mdas documenting "the same seven keys". That page documents nine (:84-85), andthe handler really does answer nine on a deployment that sets
LAYA_IDLE_UNLOAD_SECONDS.tests/test_serve.py's gate over that sentence could not see the difference. It readk.value for k in value.keys if isinstance(k, ast.Constant)off the handler's return dict, and**idleis aNonekey in that AST, so the two conditional fields were invisible and the pagematched the code exactly while both were wrong.
The gate now resolves a starred spread to the dict the handler assigned to that name, the sentence
names all nine keys plus the liveness-only arm, and a new assertion pins the pair so the reader
cannot silently lose it again. 6 insertions and 2 deletions in the page, 49 and 12 in the test.
Why
LAYA_IDLE_UNLOAD_SECONDSis a shipped, documented, forwarded setting:compose.http.yaml:59passes it through,docs/docker.md:343anddocs/http-api.md:36document itin their environment tables, and
laya/serve.py:1189-1190turns it into two response fields. So theSDK design page's "seven keys" is a shape a caller can build against and be wrong about.
The same page never mentioned the other arm either. On a deployment with
LAYA_API_KEYset,laya/serve.py:1168short-circuits toLIVENESS_ONLY = {"status": "ok"}, and the SDK alreadyhandles that deliberately:
sdk/typescript/src/response.ts:35-44requires onlystatusand checksdevice/loaded"when the server does send it",sdk/typescript/src/types.ts:179-185documentsthe withholding in the
Healthtype, andsdk/typescript/test/client.test.mjs:39is a test named"health accepts the liveness-only answer a locked-down server gives an anonymous probe". The design
page is the last copy still describing one unconditional shape, which is the copy a reader trusts
before they read the source.
How it was verified
The gate was green while the page was wrong, so the first witness is the live handler next to the
gate's own helpers, run against this tree:
That is the pre-fix tree: the gate and the page agree on seven, and the handler answers nine (or
one, unauthenticated). Re-run against the patched helper and the same page sentence:
The runtime lines are unchanged between the two runs, which is the point: only the gate and the
page moved.
Then four mutants, each applied to the committed tree, each reverted with
git checkout --afterone run:
1 failed, 1 passedrc=1 KILLED1 failed, 1 passedrc=1 KILLEDLAYA_*names1 failed, 1 passedrc=1 KILLEDidlebecomes an unresolvable call, so the pair vanishes1 failed, 1 passedrc=1 KILLEDThe fourth mutant is what makes the new assertion worth having: a future reshaping of the spread
fails with a message pointing at the handler and the page, instead of quietly dropping two fields
from the pinned set.
The page's sentence is scanned between two anchors, so it keeps the phrases the gate looks for
(
public \/health` returns,Prediction never probes health first) and stays clear of the banned three-key literal. Naming both settings inside that span is why the scanner now drops ALL-CAPS backticks: a response key of this payload is never upper case, soLAYA_IDLE_UNLOAD_SECONDSandLAYA_API_KEY` are settings, not fields.Gates:
The suite count is 497 before and after: this change extends two existing tests rather than adding
a third.
ruff check tests/test_serve.py --select=…F811reports one error, theimport reat:3765thatshadows
:12; it is there atupstream/maintoo (git show upstream/main:tests/test_serve.pygives the same single error), the CI lint path is
ruff check laya/, and removing it is unrelatedwork, so it is left alone.
Diff scan for secrets. Literal result of grepping
api[_-]?key|secret|token|password|bearer|sk-[A-Za-z0-9]|ghp_|AKIA|private[_-]?keyovergit diff HEAD~1:One hit, and it is the name of an environment variable in a sentence explaining what an
anonymous probe gets. No value, no key material, nothing credential-shaped anywhere in the diff.
Checklist
main