googleapis/mcp-toolbox · error
unexpected status code: %d (%s)
Error message
unexpected status code: %d (%s)
What it means
Error "unexpected status code: %d (%s)" thrown in googleapis/mcp-toolbox.
Source
Thrown at internal/sources/http/http.go:230
var body []byte
body, err = io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
if resp.StatusCode < 200 || resp.StatusCode > 299 {
if s.ReturnFullError {
return nil, fmt.Errorf("unexpected status code: %d, response body: %s", resp.StatusCode, string(body))
}
logger, err := util.LoggerFromContext(ctx)
if err != nil {
return nil, fmt.Errorf("unable to get logger from ctx: %s", err)
}
logger.DebugContext(ctx, "http source upstream error", "status", resp.StatusCode, "body", truncateForLog(body, maxErrorBodyLogBytes))
statusText := http.StatusText(resp.StatusCode)
if statusText != "" {
return nil, fmt.Errorf("unexpected status code: %d (%s)", resp.StatusCode, statusText)
}
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
var data any
if err = json.Unmarshal(body, &data); err != nil {
// if unable to unmarshal data, return result as string.
return string(body), nil
}
return data, nil
}
func truncateForLog(body []byte, limit int) string {
if limit <= 0 || len(body) == 0 {
return ""
}
if len(body) <= limit {
return string(body)View on GitHub (pinned to 8cc6e09de2)
When it happens
Trigger: Thrown at internal/sources/http/http.go:230 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/caba9cdc20fd7bdf.
Report an issue: GitHub.