Repository navigation
test(gateway): publish runtime config in users.self and users.prefs.get request tests - #170227
Conversation
…et request tests #169714 made getRuntimeConfig from config/io throw when no runtime snapshot is published. createOpenClawTestState resets that state, so the users.self authority cases and the users.prefs.get scope case, which use createDirectChatContext() defaults, failed method authorization with "Runtime config is not prepared" whenever CI selected this file. Publish an empty snapshot after creating test state, matching push-authority-in-process.test.ts in the same shard.
|
🦞👀 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 maintainer review before merge. What this changesThis PR publishes an empty runtime-config snapshot before seven existing Gateway profile and preference request tests. Example: The users.prefs.get test reads ui.theme=dark and revokes operator.sessions.read while the read is pending.
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — verified: source commit Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs a concrete test-fixture failure while preserving the existing authority checks. The focused patch has no actionable findings. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe request-test fixture supplies runtime config to Gateway method admission; profile and preference handlers then read worker-backed state and recheck requester authority before responding. flowchart TD
A[Test state] --> B[Published runtime config]
B --> C[Gateway request admission]
C --> D[Profile and preference handlers]
D --> E[Current authority check]
E --> F[RPC response assertions]
Technical reviewBest possible solution: Retain the explicit fixture publications and merge through the normal required checks without changing production authorization or config-loading behavior. Do we have a high-confidence way to reproduce the issue? Source establishes the failure path: test-state creation clears the snapshot, the default context uses the prepared-only reader, and request authorization reads it; the PR reports matching before-and-after test results. Is this the best way to solve the issue? Publishing the existing snapshot at fixture setup restores the required runtime precondition without mocking authorization, weakening assertions, or changing the shared reader. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 21f043cf86f5. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +3. Total +3 across 1 file. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 12, 2026, 4:45 PM ET / 20:45 UTC. |
|
Merged via squash.
|
…et request tests (openclaw#170227) openclaw#169714 made getRuntimeConfig from config/io throw when no runtime snapshot is published. createOpenClawTestState resets that state, so the users.self authority cases and the users.prefs.get scope case, which use createDirectChatContext() defaults, failed method authorization with "Runtime config is not prepared" whenever CI selected this file. Publish an empty snapshot after creating test state, matching push-authority-in-process.test.ts in the same shard.
What Problem This Solves
Fixes: seven
users-preferences.test.tscases (users.self keeps its original … authority×6 andusers.prefs.get retains its original scope) fail withRuntime config is not preparedwhenever CI selects that file, for example theagentic-gateway-methods-hosted-2shard on #170077 (run 38289790852, job 114947303634).User Impact
No user-visible change. PRs that touch this file's imports (such as
server-plugin-in-process-dispatch.ts) stop failing thegateway-methods-isolatedshard.Why This Change Was Made
#169714 turned
getRuntimeConfigfromconfig/iointoreadRuntimeConfig, which reads the published runtime snapshot and throws when nothing was prepared instead of cold-loading config.createOpenClawTestStateresets runtime-config state when it applies its env, and these seven cases drivehandleGatewayRequestthroughcreateDirectChatContext()defaults, so method authorization (authorizeGatewayMethod,assertCurrentinsession-mutation-guards.ts) hit the throwing reader. The other nine cases pass because they use a context with its owngetRuntimeConfigor call handlers directly.The two tests now publish an empty runtime snapshot right after creating their state: the precondition a running Gateway always has, and the idiom
push-authority-in-process.test.tsalready uses in the same shard. Test-state cleanup resets the snapshot again, so nothing leaks between tests.This was never intermittent. It has been deterministic on
mainsince #169714, but it only shows up when changed-file selection schedules this file. The 16/16 local pass on the #170077 head ran pre-#169714 code, while PR CI tests the merge ref. The greenmainpush run checked (32feb396e066) did not schedule the gateway-methods shard. No othergatewayMethodsIsolatedTestFilesentry uses defaultcreateDirectChatContext()without publishing config (users-role.worker.test.tspasses its owngetRuntimeConfig).Evidence
origin/main24dec4d6c370:pnpm test src/gateway/server-methods/users-preferences.test.ts --maxWorkers=1gives 7 failed / 9 passed, the same error and stacks as the CI job.gateway-methods-isolatedproject (Vitest 67.7s, wall 80s on a loaded dev Mac).pnpm test src/gateway/server-methods/push-authority-in-process.test.ts --maxWorkers=1: 3 passed under thegateway-methodsproject.node scripts/run-tsgo-core-test-shards.mjs --changed-paths-jsonfor the file:gateway-methodsgraph passed.oxfmt --checkandoxlintare clean.