fix(cli): send download id as ?id= query param to match HTTP API#467
Open
StressTestor wants to merge 2 commits into
Open
fix(cli): send download id as ?id= query param to match HTTP API#467StressTestor wants to merge 2 commits into
StressTestor wants to merge 2 commits into
Conversation
StressTestor
pushed a commit
to StressTestor/Surge
that referenced
this pull request
May 31, 2026
Broaden the SurgeDM#456 regression test to exercise every ExecuteAPIAction caller (pause/resume/delete) rather than just pause, so a future action-specific routing regression is caught. Addresses review feedback on SurgeDM#467.
SuperCoolPencil
approved these changes
May 31, 2026
Member
SuperCoolPencil
left a comment
There was a problem hiding this comment.
LGTM. Thanks for contributing 🚀
StressTestor
added a commit
to StressTestor/Surge
that referenced
this pull request
Jun 1, 2026
Broaden the SurgeDM#456 regression test to exercise every ExecuteAPIAction caller (pause/resume/delete) rather than just pause, so a future action-specific routing regression is caught. Addresses review feedback on SurgeDM#467.
ExecuteAPIAction built the request path as "<endpoint>/<id>" (e.g. POST /pause/<id>), but the HTTP API registers exact routes and reads the id from the "id" query parameter (withRequiredID in cmd/http_api.go), so pause/resume/delete/open returned 404 against a remote daemon. Send the id as ?id= (url-escaped), matching the browser extension and internal/core/remote_service.go. Fixes SurgeDM#456
Broaden the SurgeDM#456 regression test to exercise every ExecuteAPIAction caller (pause/resume/delete) rather than just pause, so a future action-specific routing regression is caught. Addresses review feedback on SurgeDM#467.
4ed0a4f to
9ce9dc6
Compare
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.
What
The CLI's
ExecuteAPIAction(cmd/utils.go) built the request path as<endpoint>/<id>(e.g.POST /pause/<id>), but the HTTP API registers exact routes (/pause,/resume,/delete,/open-file,/open-folder, …) and reads the download id from theidquery parameter viawithRequiredID(cmd/http_api.go). A path segment doesn't match the registered routes, sopause,resume,rm, andopenreturned 404 Not Found against a remote Surge daemon.Fix
Send the id as
?id=<url-escaped>, matching the server's contract — and what the browser extension (/pause?id=...) andinternal/core/remote_service.go(/pause?id=" + url.QueryEscape(id)) already use. One-line change inExecuteAPIAction; the CLI was the only client using the path form.Testing
TestExecuteAPIAction_SendsIDAsQueryParam(cmd/http_api_test.go): it registers the real routes viaregisterHTTPRoutes+httptest.NewServer, points the CLI at it viaSURGE_HOST, and asserts the server receives the id.<endpoint>/<id>path the test fails withserver error: 404 Not Found; with?id=it passes.go test ./...,gofmt,go vet ./..., andgolangci-lint run(v2) all clean.Fixes #456
Greptile Summary
This PR fixes a 404 regression in the CLI's
ExecuteAPIActionfunction: it was building request paths as<endpoint>/<id>(path segment form), but the HTTP server only registers exact routes and reads the download ID from the?id=query parameter viawithRequiredID. The fix aligns the CLI with the browser extension andinternal/core/remote_service.go, which already used the correct query-parameter form.cmd/utils.go: One-line change replacingfmt.Sprintf(\"%s/%s\", endpoint, id)withfmt.Sprintf(\"%s?id=%s\", endpoint, url.QueryEscape(id)), with an explanatory comment.cmd/http_api_test.go: AddsTestExecuteAPIAction_SendsIDAsQueryParam, a regression test that registers real HTTP routes viaregisterHTTPRoutes, starts a test server, and asserts all threeExecuteAPIActioncallers (pause, resume, delete) correctly deliver the ID as a query parameter.Confidence Score: 5/5
Safe to merge — the change is a targeted one-line fix to a well-understood API contract mismatch, backed by a regression test against real routes.
The fix is minimal and precisely targeted: it corrects the query-parameter format in a single function that all affected CLI commands share, and the new test exercises all three callers against a real HTTP mux to prevent future regressions.
No files require special attention.
Important Files Changed
?id=query parameter instead of a path segment; correctly usesurl.QueryEscapeand adds an explanatory comment.ExecuteAPIActioncallers (pause/resume/delete) against a real registered HTTP mux; test structure and assertions are correct.Reviews (3): Last reviewed commit: "test(cli): cover resume and delete in Ex..." | Re-trigger Greptile