Repository navigation
fix(pm-dispatch): scope sessions directory to REPO_DIRS for OIDC callers (#2903) - #2907
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 21 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99dd7fff4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Directory scoping (issue #2903) runs before ANY side effect: the | ||
| // tracking issue, queue task and session below are all created after | ||
| // this line, so a rejected directory leaves nothing behind. | ||
| const directory = resolveSessionDirectory(caller.type, body.repo, body.directory, REPO_DIRS); |
There was a problem hiding this comment.
Catch directory-validation failures at the HTTP boundary
For an authenticated OIDC request specifying a foreign directory, this new validation rejects the request but does not return the documented HTTP 400. The routing handler returns the handleSessions promise without awaiting it inside its try, so the ValidationError bypasses its catch block and reaches Bun as an unhandled handler rejection, producing HTTP 500 instead. Await the session handler within that error boundary and add an HTTP-level rejection test; the current unit tests only verify that the helper throws.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b1d7a8e: both handlers are now awaited inside the error boundary so the directory ValidationError maps to the documented HTTP 400, and test/server.test.ts pins it end-to-end (OIDC + foreign directory → 400 with no side effect possible; omitted/own-clone → passes validation). Server entry is also guarded by import.meta.main so tests can import the handler without binding ports.
Closes #2903.
OIDC callers could pass any
directoryto POST /v1/sessions and get a session anywhere on the laptop, escaping the repo allowlist entirely.resolveSessionDirectory()(new invalidate.ts, unit-tested) now restricts OIDC callers to omitted (= repo primary clone) or exactly the repo clone, enforced inhandleSessionsbefore the tracking issue, queue task, or session is created (400 otherwise). Bearer callers keep the free-form directory as a deliberate documented choice (README). Trailing slashes are normalized.Tests:
bun testinpm-stack/dispatch— 46 pass, 0 fail (7 new scoping cases).bunx tsc --noEmitfails identically on clean main (missing bun types — pre-existing/environmental).Need help on this PR? Tag
@codesmith-botwith what you need.