Repository navigation
fix(hooks): reject malformed session keys and honor immediate wake overrides - #166406
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. Reviewed October 6, 2026, 10:56 PM ET / October 7, 2026, 02:56 UTC. ClawSweeper reviewWhat this changesThe PR rejects malformed agent-hook session keys, honors immediate timing overrides from webhook transforms, and adds HTTP regressions and documentation. Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: both fixes remain necessary on the pinned main branch, and no introduced correctness defect was found. The required test-cost evidence remains incomplete. Priority: P2 Review scores
Verification
How this fits togetherGateway webhooks turn authenticated HTTP requests into wake events or agent runs. Payload validation and configured transforms determine routing and timing before dispatch. flowchart TD
A[HTTP hook request] --> B[Authentication]
B --> C[Payload validation]
B --> D[Configured mapping and transform]
C --> E[Routing and session policy]
D --> E
E --> F[Wake event]
E --> G[Agent run]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +8, Tests +44, Docs +4. Total +56 across 4 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep routing validation at hook ingress and apply both supported timing overrides through the existing mapping owner. Do we have a high-confidence way to reproduce the issue? Yes, from source: an authenticated agent request with a blank or non-string key reaches fallback routing on pinned main, and a transform returning now cannot override a deferred mapping. This read-only review did not execute those scenarios. Is this the best way to solve the issue? Yes: the patch repairs the existing normalization and mapping owners without adding a competing path, and preserves valid input and omitted-key behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c48607980ace. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…errides (openclaw#166406) * fix(hooks): reject malformed agent session keys * fix(hooks): honor immediate wake transform overrides Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Two
/hooksendpoint behaviors did something other than what the request asked for, without an error:/hooks/agentrequest with a malformedsessionKey(null, a number, boolean, object, array, empty, or whitespace) returned 200 and dispatched to the fallback session, so the caller's routing intent was dropped without telling them.next-heartbeat, a transform returningmode: "now"orwakeMode: "now"was ignored. Both the wake HTTP response and the agent job stayed deferred.Why This Change Was Made
normalizeAgentPayloadinsrc/gateway/hooks.tsdiscarded supplied but invalid keys instead of rejecting them (behavior since1ed5ca3fdeb). A supplied key must now be a valid session key, or the request gets 400 with nothing dispatched. An omitted key still uses the documented default.mergeActioninsrc/gateway/hooks-mapping.tsonly recognized overrides toward the deferred mode (sinceaeb54555558). It now honors a transform's immediate override as well. Invalid transform values keep the existing fallback and validation.User Impact
Hook callers get a clear 400 for bad session keys instead of a silent reroute, and transforms can make a wake immediate.
Evidence
nowoverride stayednext-heartbeatbefore and is honored after, in both the HTTP response and the job.check-changedgate passed remotely, andserver.hooks.test.tspassed 19/19 on Linux.Found but not changed here: after a restart, an immediate wake followed quickly by an agent request using
waitForCompletioncan get a recorded 502 (AgentDatabaseRegistryChangedError) from the registry-ownership guard. This is being investigated separately; the guard is correct and stays.