Skip to content

Fix search_repositories query parameter URL encoding#3235

Merged
lpcox merged 1 commit intomainfrom
fix/url-encode-search-query
Apr 5, 2026
Merged

Fix search_repositories query parameter URL encoding#3235
lpcox merged 1 commit intomainfrom
fix/url-encode-search-query

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Apr 5, 2026

Problem

TestRestBackendCaller_SearchRepositories_APIError was failing because the search_repositories case in restBackendCaller.CallTool was not URL-encoding the query parameter before embedding it in the API path.

Queries containing spaces or special characters (e.g. language:go stars:>1000) produced malformed HTTP request URIs, causing the upstream server to reject them with HTTP 400 instead of the expected status code.

Fix

Use url.QueryEscape() to properly encode the query value before building the API path.

Verification

make agent-finished passes — all unit and integration tests green.

The search_repositories case in restBackendCaller.CallTool was not
URL-encoding the query parameter before embedding it in the API path.
Characters like spaces and '>' in queries (e.g. 'language:go stars:>1000')
produced malformed HTTP request URIs, causing the upstream server to
reject them with HTTP 400 instead of forwarding to the /search/repositories
endpoint.

Use url.QueryEscape to properly encode the query value.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 5, 2026 22:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes malformed GitHub REST API requests generated by the proxy’s restBackendCaller for the search_repositories tool by URL-encoding the q query parameter before constructing the upstream request path.

Changes:

  • URL-encode search_repositories’s query argument via url.QueryEscape() when building /search/repositories API paths.
Show a summary per file
File Description
internal/proxy/proxy.go Escapes the q query parameter for search_repositories to prevent invalid request URIs and upstream 400s.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

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.

2 participants