googleapis/mcp-toolbox · error
email not found in response: %v
Error message
email not found in response: %v
What it means
The decoded tokeninfo JSON contained no top-level `email` key — the credential's token does not carry an email identity (e.g. a token type without an associated user/service-account email).
Source
Thrown at internal/sources/util.go:117
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, "@")
case "postgres":
// service account email used for IAM should trim the suffix
username = strings.TrimSuffix(fullEmail, ".gserviceaccount.com")
default:View on GitHub (pinned to 8cc6e09de2)
Solutions
- Use a credential that has an associated email (service account or user ADC)
- Check the token type and scopes
- Inspect the logged response JSON
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/sources/util.go:117 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/073756252f46d9b5.
Report an issue: GitHub.