googleapis/mcp-toolbox · error
error parsing JSON: %v
Error message
error parsing JSON: %v
What it means
json.Unmarshal failed to decode the tokeninfo response body into a map — the endpoint returned a body that is not valid JSON, despite the 200 status.
Source
Thrown at internal/sources/util.go:112
if err != nil {
return "", fmt.Errorf("failed to call tokeninfo endpoint: %w", err)
}
defer resp.Body.Close()
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("error reading response body %d: %s", resp.StatusCode, string(bodyBytes))
}
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("tokeninfo endpoint returned non-OK status %d: %s", resp.StatusCode, string(bodyBytes))
}
// Unmarshal response body and get `email`
var responseJSON map[string]any
err = json.Unmarshal(bodyBytes, &responseJSON)
if err != nil {
return "", fmt.Errorf("error parsing JSON: %v", err)
}
emailValue, ok := responseJSON["email"]
if !ok {
return "", fmt.Errorf("email not found in response: %v", err)
}
fullEmail, ok := emailValue.(string)
if !ok {
return "", fmt.Errorf("email field is not a string")
}
var username string
// Format the username based on Database Type
switch strings.ToLower(dbType) {
case "mysql":
username, _, _ = strings.Cut(fullEmail, "@")
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Retry after transient malformed responses
- Log and inspect the raw body bytes
- Report if the endpoint consistently returns non-JSON
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at internal/sources/util.go:112 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/8f029c4715bbb2cb.
Report an issue: GitHub.