vxcontrol/pentagi · error · Fatal
there need to try to access an endpoint with an invalid meth
Error message
there need to try to access an endpoint with an invalid method
What it means
Thrown in tavily.parseHTTPResponse when Tavily answers HTTP 405 Method Not Allowed, mapped to "there need to try to access an endpoint with an invalid method". The route exists but rejected POST — meaning the request reached something that does not accept POST on /search. Classified Fatal, since the method is fixed in code and retrying cannot change the outcome.
Source
Thrown at backend/pkg/tools/searchers/tavily.go:158
func (t *tavily) parseHTTPResponse(ctx context.Context, resp *http.Response) (string, error) {
switch resp.StatusCode {
case http.StatusOK:
var respBody tavilySearchResult
if err := json.NewDecoder(resp.Body).Decode(&respBody); err != nil {
return "", Fatal(fmt.Errorf("failed to decode response body: %v", err))
}
return t.buildTavilyResult(ctx, &respBody), nil
case http.StatusBadRequest:
return "", Fatal(fmt.Errorf("request is invalid"))
case http.StatusUnauthorized:
return "", Fatal(fmt.Errorf("API key is wrong"))
case http.StatusForbidden:
return "", Fatal(fmt.Errorf("the endpoint requested is hidden for administrators only"))
case http.StatusNotFound:
return "", Fatal(fmt.Errorf("the specified endpoint could not be found"))
case http.StatusMethodNotAllowed:
return "", Fatal(fmt.Errorf("there need to try to access an endpoint with an invalid method"))
case http.StatusTooManyRequests:
return "", Retryable(fmt.Errorf("there are requesting too many results"), 0)
case http.StatusInternalServerError:
return "", Retryable(fmt.Errorf("there had a problem with our server. try again later"), 0)
case http.StatusBadGateway:
return "", Retryable(fmt.Errorf("there was a problem with the server. Please try again later"), 0)
case http.StatusServiceUnavailable:
return "", Retryable(fmt.Errorf("there are temporarily offline for maintenance. please try again later"), 0)
case http.StatusGatewayTimeout:
return "", Retryable(fmt.Errorf("there are temporarily offline for maintenance. please try again later"), 0)
default:
return "", Fatal(fmt.Errorf("unexpected status code: %d", resp.StatusCode))
}
}
func (t *tavily) buildTavilyResult(ctx context.Context, result *tavilySearchResult) string {
var writer strings.Builder
writer.WriteString("# Answer\n\n")View on GitHub (pinned to ea665308ba)
Solutions
- Test with curl -X POST https://api.tavily.com/search -H 'Content-Type: application/json' -d '{...}' to confirm whether POST is blocked in your network path.
- Inspect proxy/security appliance rules that may rewrite or restrict POST to api.tavily.com and allow-list the host.
- Verify the target URL has not been overridden to a gateway/mock lacking the POST route.
- Check Tavily API docs for method changes and update search() if POST is no longer correct.
- If a mock/self-hosted server is used in dev, add the POST /search handler to it.
Example fix
// before: mock server only handles GET
mux.HandleFunc("/search", getOnlyHandler)
// after: register POST (and method check)
mux.HandleFunc("/search", func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost { w.WriteHeader(http.StatusMethodNotAllowed); return }
searchHandler(w, r)
}) Defensive patterns
Strategy: validation
Validate before calling
// confirm POST is accepted before relying on the engine
req, _ := http.NewRequest(http.MethodOptions, "https://api.tavily.com/search", nil)
resp, err := http.DefaultClient.Do(req)
if err == nil {
allow := resp.Header.Get("Allow")
if allow != "" && !strings.Contains(allow, http.MethodPost) {
return fmt.Errorf("POST not allowed on /search (Allow: %s)", allow)
}
} Try / catch
if err != nil {
if strings.Contains(err.Error(), "invalid method") {
// inspect proxy/gateway method filters; switch engine meanwhile
return fallbackSearcher.Handle(ctx, req)
}
return err
} Prevention
- Allow-list api.tavily.com including POST bodies in proxy/security appliance rules.
- Keep dev mocks method-faithful: implement POST /search, not GET.
- Check gateway route configs when fronting external APIs.
- Validate with curl -X POST from the deployment environment during setup.
When it happens
Trigger: search() issues http.MethodPost to the endpoint and receives 405: an intercepting proxy/API gateway only allows GET on that path, a misconfigured base URL points to a different service, or Tavily changes the endpoint's accepted method.
Common situations: Captive proxies or security appliances that block POST bodies and rewrite requests; a self-hosted Tavily-compatible mock that implements only GET; pasting the endpoint into an API gateway that maps only GET routes; caching middlewares stripping the method semantics.
Related errors
- the specified endpoint could not be found
- failed to create http client: %w
- failed to create http client: %w
- failed to do request: %v
- failed to decode response body: %v
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/08f829ebf3985ebb.
Report an issue: GitHub.