[PR #167] [MERGED] fix: apply constructed opts to Google search service creation #210

Closed
opened 2026-06-06 22:09:42 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/167
Author: @mason5052
Created: 3/2/2026
Status: Merged
Merged: 3/2/2026
Merged by: @asdek

Base: feature/next_releaseHead: fix/google-search-opts-unused


📝 Commits (1)

  • be0dc7e fix: apply constructed opts to Google search service creation

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 backend/pkg/tools/google.go (+1 -1)

📄 Description

Description of the Change

Problem

In newSearchService() (backend/pkg/tools/google.go), the opts slice is correctly constructed with both the API key and (when configured) a proxy HTTP client:

opts := []option.ClientOption{
    option.WithAPIKey(g.apiKey),
}

if g.proxyURL != "" {
    opts = append(opts, option.WithHTTPClient(&http.Client{
        Transport: &http.Transport{
            Proxy: func(req *http.Request) (*url.URL, error) {
                return url.Parse(g.proxyURL)
            },
        },
    }))
}

However, the actual service creation call ignores opts entirely and passes a hardcoded option.WithAPIKey(g.apiKey):

svc, err := customsearch.NewService(ctx, option.WithAPIKey(g.apiKey))  // opts is unused!

This means proxy configuration has no effect on Google search requests, even when proxyURL is set.

Solution

Replace the hardcoded argument with opts...:

svc, err := customsearch.NewService(ctx, opts...)

This ensures the proxy HTTP client (when configured) is actually applied to the Google Custom Search API client.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Areas Affected

  • External Integrations (Google Custom Search API)

Testing and Verification

Test Configuration

PentAGI Version: master @ e97bbe5
Docker Version: N/A (code review + existing tests)
Host OS: Windows 11
LLM Provider: N/A

Test Steps

  1. Identified opts variable built but never passed to NewService
  2. Verified the same proxy pattern works correctly in other tools (tavily.go, traversaal.go, browser.go)
  3. Confirmed existing google_test.go tests pass (TestGoogleNewSearchServiceWithoutProxy, TestGoogleNewSearchServiceWithProxy)

Test Results

  • Single-token change: option.WithAPIKey(g.apiKey) -> opts...
  • When proxyURL is empty, opts contains only option.WithAPIKey(g.apiKey), producing identical behavior to the current code

Security Considerations

This fix improves security by ensuring proxy configuration is honored. When a proxy is configured (e.g., for traffic inspection or network isolation), the current code silently bypasses it.

Performance Impact

None. The only change is which ClientOption values are passed to NewService.

Deployment Notes

Backward-compatible. When proxyURL is empty, behavior is identical.

Checklist

Code Quality

  • My code follows the project's coding standards
  • I have added/updated necessary documentation
  • All new and existing tests pass
  • I have run go fmt and go vet (for Go code)

Security

  • I have considered security implications
  • Changes maintain or improve the security model
  • Sensitive information has been properly handled

Compatibility

  • Changes are backward compatible
  • Dependencies are properly updated

Documentation

  • Documentation is clear and complete
  • Comments are added for non-obvious code

Additional Notes

Resubmission of #165 (which was closed due to branch contamination). This PR contains only the single-line fix.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/167 **Author:** [@mason5052](https://github.com/mason5052) **Created:** 3/2/2026 **Status:** ✅ Merged **Merged:** 3/2/2026 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `feature/next_release` ← **Head:** `fix/google-search-opts-unused` --- ### 📝 Commits (1) - [`be0dc7e`](https://github.com/vxcontrol/pentagi/commit/be0dc7ee0e76a8484c93d5ab4e674f7eb1070185) fix: apply constructed opts to Google search service creation ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/pkg/tools/google.go` (+1 -1) </details> ### 📄 Description ### Description of the Change #### Problem In `newSearchService()` (`backend/pkg/tools/google.go`), the `opts` slice is correctly constructed with both the API key and (when configured) a proxy HTTP client: ```go opts := []option.ClientOption{ option.WithAPIKey(g.apiKey), } if g.proxyURL != "" { opts = append(opts, option.WithHTTPClient(&http.Client{ Transport: &http.Transport{ Proxy: func(req *http.Request) (*url.URL, error) { return url.Parse(g.proxyURL) }, }, })) } ``` However, the actual service creation call ignores `opts` entirely and passes a hardcoded `option.WithAPIKey(g.apiKey)`: ```go svc, err := customsearch.NewService(ctx, option.WithAPIKey(g.apiKey)) // opts is unused! ``` This means **proxy configuration has no effect** on Google search requests, even when `proxyURL` is set. #### Solution Replace the hardcoded argument with `opts...`: ```go svc, err := customsearch.NewService(ctx, opts...) ``` This ensures the proxy HTTP client (when configured) is actually applied to the Google Custom Search API client. ### Type of Change - [x] Bug fix (non-breaking change which fixes an issue) ### Areas Affected - [x] External Integrations (Google Custom Search API) ### Testing and Verification #### Test Configuration ```yaml PentAGI Version: master @ e97bbe5 Docker Version: N/A (code review + existing tests) Host OS: Windows 11 LLM Provider: N/A ``` #### Test Steps 1. Identified `opts` variable built but never passed to `NewService` 2. Verified the same proxy pattern works correctly in other tools (tavily.go, traversaal.go, browser.go) 3. Confirmed existing `google_test.go` tests pass (TestGoogleNewSearchServiceWithoutProxy, TestGoogleNewSearchServiceWithProxy) #### Test Results - Single-token change: `option.WithAPIKey(g.apiKey)` -> `opts...` - When `proxyURL` is empty, `opts` contains only `option.WithAPIKey(g.apiKey)`, producing identical behavior to the current code ### Security Considerations This fix **improves security** by ensuring proxy configuration is honored. When a proxy is configured (e.g., for traffic inspection or network isolation), the current code silently bypasses it. ### Performance Impact None. The only change is which `ClientOption` values are passed to `NewService`. ### Deployment Notes Backward-compatible. When `proxyURL` is empty, behavior is identical. ### Checklist #### Code Quality - [x] My code follows the project's coding standards - [x] I have added/updated necessary documentation - [x] All new and existing tests pass - [x] I have run `go fmt` and `go vet` (for Go code) #### Security - [x] I have considered security implications - [x] Changes maintain or improve the security model - [x] Sensitive information has been properly handled #### Compatibility - [x] Changes are backward compatible - [x] Dependencies are properly updated #### Documentation - [x] Documentation is clear and complete - [x] Comments are added for non-obvious code ### Additional Notes Resubmission of #165 (which was closed due to branch contamination). This PR contains only the single-line fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:42 -04:00
yindo closed this issue 2026-06-06 22:09:43 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#210