Skip to content

Reject non-boolean router dispatcher values - #23

Merged
T-Crypt merged 1 commit into
oh-my-pocketfrom
fix/router-dispatcher-strict
Oct 14, 2026
Merged

T-Crypt merged 1 commit into
oh-my-pocketfrom
fix/router-dispatcher-strict

Conversation

@T-Crypt

@T-Crypt T-Crypt commented Oct 14, 2026

Copy link
Copy Markdown
Owner

What changed. checkRouter rejects a non-boolean dispatcher and answers with a 400. The guard lives in src/server/routers.ts at lines 533 to 535. A new test in test/routers.test.ts sends an object dispatcher and expects the rejection. It also saves true and false. It checks the stored result in each case.

Proof. npm run check passes with no errors. npm run lint passes with no findings. The routers suite passes 6 of 6.

Review verdict. The diff adds one guard and one test. It changes no existing path. It is safe to review.

Scope. This PR holds only the fix commit. PR 22 keeps the validation scratch and stays separate. This PR needs a reviewer before it merges. I will not merge it.

@T-Crypt
T-Crypt marked this pull request as ready for review October 14, 2026 15:07

@T-Crypt T-Crypt left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkRouter now rejects any dispatcher value that is not a boolean, with a specific 400 message. Before this change, every value was accepted and the saved router carried dispatcher: true only when the value was exactly true. A client that sent something like dispatcher: { blockedTools: ["bash"] } therefore got a router saved that looks like a dispatcher but never blocks bash, edit, or write, and the mistake only shows up later, in a session that can run commands it should not. The guard turns that silent misconfiguration into a loud failure at save time. false and an omitted value are still accepted and both normalize to "not a dispatcher"; the PR pins that down in tests.

Verdict: clean. No findings, nothing blocking.

Considered and cleared:

  • Files saved before this fix that hold a non-boolean dispatcher keep loading. The load path (savedRouters, src/server/routers.ts:342) does not revalidate, and the runtime check is a strict === true (src/server/extensions/routers.ts:42), so such files behave exactly as before.
  • The router editor shows a stale non-boolean value with the checkbox off (web/routers.js:140 reads router.dispatcher === true), and a re-save rewrites the file in normalized form.

@T-Crypt
T-Crypt merged commit 78f90d0 into oh-my-pocket Oct 14, 2026
2 checks passed
@T-Crypt
T-Crypt deleted the fix/router-dispatcher-strict branch October 14, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant