fix(contracts): params validation rejects only unknown keys; accepted params + results are checked after the handler
Handlers own their documented domain codes (4006 missing session_id, 4015 bad
url, 4009 orphan claim); the contract's job on the way in is the one check no
handler performs — an unknown key (4000 with the key path). Missing/mistyped
fields are re-checked AFTER a successful handler answer under the strict
test policy, so a contract narrower than the wire still fails the suite.
Two models widened from the suite: SeedMessage (clients forward stored rows
verbatim), tool.complete.args (mirrored child rows omit it). Tests that
drove session.activate with prompt params (and vice versa) or stubbed
_live_session_payload with a bare {session_id} now send the real shapes.
This commit is contained in:
@@ -92,7 +92,7 @@ def _register(req: ServerRequest) -> None:
|
||||
raise RuntimeError(f"server request {req.method!r} has no contract in tui_gateway/contracts")
|
||||
_, problem = contracts.validate_params(contract, {"session_id": req.sid, **req.params})
|
||||
if problem is not None:
|
||||
raise ValueError(problem)
|
||||
raise ValueError(problem) # a key the renderer's typed handler would never read: our bug
|
||||
with _lock:
|
||||
_open[req.id] = req
|
||||
_write(req.frame())
|
||||
|
||||
Reference in New Issue
Block a user