fix(tmux): don't resolve an empty pane ID to an unrelated mission - #33
Open
swade1987 wants to merge 2 commits into
Open
fix(tmux): don't resolve an empty pane ID to an unrelated mission#33swade1987 wants to merge 2 commits into
swade1987 wants to merge 2 commits into
Conversation
`agenc tmux resolve-mission ""` was returning a real mission UUID instead
of printing nothing. The server's /missions handler only takes the
pane-specific lookup path when tmux_pane is non-empty; an empty value
falls through to the general mission-list endpoint, and this command
then printed responses[0].ID - whatever mission happened to be first in
that unrelated list - rather than treating it as a lookup miss.
Adds an early return for an empty pane ID, matching the command's
documented contract ("prints nothing if no active mission is
associated with the pane"). Verified: resolve-mission "" now prints
nothing, and a real pane ID still resolves correctly.
Signed-off-by: Steven Wade <steven@stevenwade.co.uk>
Uncovered while verifying the previous commit: the request URL was built
via raw string concatenation ("/missions?tmux_pane="+paneID) with no
escaping. A pane ID containing "#" - exactly what an accidentally
unexpanded tmux format placeholder like "#{pane_id}" looks like - has
everything from "#" onward parsed as a URL fragment and silently
dropped before the request is sent. The server then sees an empty
tmux_pane value and falls through to the same general-mission-list path
the previous commit fixed for a truly empty input, so this command
would print an unrelated mission's ID instead of nothing.
Confirmed with a standalone url.Parse of the exact string this command
builds: RawQuery ends up "tmux_pane=", Fragment ends up "{pane_id}".
Verified: resolve-mission "#{pane_id}" now prints nothing (previously
printed a real, unrelated mission UUID), a real pane ID still resolves
correctly, and the empty-string case from the previous commit is
unaffected.
Signed-off-by: Steven Wade <steven@stevenwade.co.uk>
Owner
|
Oops that sounds like a bug; will get to this when I get my Claude chunking through issues |
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.
(This post authored by my AgenC)
Bug
agenc tmux resolve-missionwas printing a real (but unrelated) mission UUID for pane IDs that should have resolved to nothing, in two related cases:resolve-mission "").#, such as an accidentally-unexpanded tmux format placeholder passed in literally — e.g.resolve-mission "#{pane_id}"(this is what actually surfaced the bug for me, while building a tmux status-bar popup — see [Feature] tmux status-bar popup: mission ID + checkout directory for a window #32).Root cause
Two distinct issues, same downstream symptom:
1. Empty pane ID falls through to the general mission list.
handleListMissionsonly takes the pane-specific lookup path whentmux_paneis non-empty:An empty value falls through to the general mission-list endpoint instead.
tmux resolve-missionthen doesfmt.Print(responses[0].ID)— printing whatever mission happens to be first in that unrelated list, rather than treating an empty pane ID as a lookup miss.2. The pane ID isn't URL-escaped before being sent. The request URL is built via raw string concatenation:
"/missions?tmux_pane="+paneID. A pane ID containing#has everything from#onward parsed as a URL fragment and silently dropped before the request is sent — confirmed directly with a standaloneurl.Parseof the exact string this command builds:So the server receives an empty
tmux_pane, hits issue #1's fallthrough, and this command prints an unrelated mission's ID again — the two bugs compound, and #2 is the more likely real-world trigger, since#is exactly what any accidentally-unexpanded tmux format placeholder looks like.Fix
Two commits:
runTmuxResolveMissionwhen the pane ID is empty, before any server/database call.url.QueryEscapethe pane ID before building the request URL, so a value containing#(or any other URL-special character) can no longer be silently truncated.Verification
Built the binary from this branch and tested directly against a real local AgenC server/database:
Also ran
go build ./...andgo test ./cmd/...(both pass) from this branch.