Repository navigation
fix(session): explain selector misses instead of protocol-validation-failed - #1149
Merged
Merged
Conversation
…failed A hunk session command that selects its window with --repo or --session-path looks the session up before authorization. When that lookup matched no single session, the daemon collapsed the error into a redacted protocol-validation-failed, so callers in a different checkout (for example another git worktree) could not tell why the command failed. Authorize a selector miss as list instead, since the lookup error reveals nothing list would not, and answer it with the lookup error without dispatching the action. Session-scoped callers still learn nothing, and malformed bodies stay redacted.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
|
…on failure Move selector-miss handling from Hunk's adapter into the generic broker. `resolve` now throws SessionBrokerTargetResolutionError, and handleAuthenticatedControl authorizes only its disclosure (against `list` by default), answers with the message, and never runs `handle`. This removes the implicit "operation is list but action is not" check, the second lookup in the handler, and the 409 retry path that existed only because the lookup error was lost between resolve and handle. Audit events now record the disclosure as outcome `target-resolution-failed` instead of an ordinary authenticated `list`. The response a caller receives is unchanged (a signed, target-specific 400 carrying the lookup error), so no session wire or broker protocol revision bump is needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
hunk sessioncommands that select a window with--repoor--session-pathfail with a barehunk: protocol-validation-failedwhen the path matches no live window. A user running Claude Code and Hunk side by side in herdr hit this on every reload. Claude's shell was in a different git worktree from the Hunk window, so--repo .matched nothing. With no reason in the error, Claude reported that "the Hunk session disconnected during the reload", even though the window was fine.Reproduced on 0.23.0 and
main. Open the window on a main checkout, then run from a sibling worktree:The same happens for every selector command, including
get,review, andcomment list, and with no live sessions at all. Selecting by session ID already gives a properNo active session matches sessionId ….Cause
A path selector names its session only after a lookup, so
sessionApiAuthorizationFactsresolves the session before authorization. When the lookup threw,handleAuthenticatedControltreated it like a malformed body and returned the redactedprotocol-validation-failed, dropping the real message.Approach
list. The lookup error (no match, or which sessions match ambiguously) never reveals more thanlistdoes.list(the Hunk CLI) get the real message.list, so it is denied and still learns nothing about other windows.409retry error instead of running a command it was never authorized for.After:
Non-goals: no change to selection semantics. Worktrees still don't match each other's windows, and the explicit-ID path is unchanged. Skill guidance for worktree workflows is a separate follow-up PR.
Tests
brokerServer.test.ts, at the HTTP level with real signed callers:getandreloadwith a missing repo selector return the lookup error and dispatch nothing.409and dispatches nothing.test/session/cli.test.ts, black-box CLI against a live window:get --repoandreload --repofor a path no window shows explain the miss. This suite is Linux-only (util-linuxscript). I ran it inoven/bun:1.4.2: all 8 pass, and the new test fails on the old code withhunk: protocol-validation-failed.get,review,comment listandreloadwith--repo .all print the new message, and from the main checkoutreload --repo .still works. With no live sessions,reload --repo .now prints the miss as well.Commands run:
bun run typecheck,bun run lint,bun run deps:check: pass.bun run test: 4558 pass, 1 fail. The failure isJujutsu source reading > logs unexpected source failures…, which fails identically onmainhere becausejjisn't installed on this machine.bun run test:session-broker-node: pass.bun run format:check: changed files pass; only untracked localscratch/files are flagged.bun run knip: flags the same 3 findings asmain, none in changed files.Platforms: macOS (unit and manual), Linux in Docker (session CLI suite). Windows not tested; the change uses no platform-specific paths.
Follow-ups
Timed out waiting for the Hunk session daemon…while the window still finishes the reload.