googleapis/mcp-toolbox · error
failed to parse project number %q as int64: %w
Error message
failed to parse project number %q as int64: %w
What it means
The source extracts the project number string from the second segment of the GetProject resource name and converts it with strconv.ParseInt. This error wraps a strconv failure when that segment is not a valid int64. Like the format error, it is a defensive guard against an unexpected Resource Manager response and is rare in practice.
Source
Thrown at internal/sources/dataplex/dataplex.go:116
projectsClient.Close()
return nil, fmt.Errorf("failed to get project details for project %q: %w", r.Project, err)
}
parts := strings.Split(proj.Name, "/")
if len(parts) < 2 {
client.Close()
dataScanClient.Close()
dataProductClient.Close()
projectsClient.Close()
return nil, fmt.Errorf("unexpected project resource name format: %q", proj.Name)
}
projectNumberStr := parts[1]
projectNumber, err := strconv.ParseInt(projectNumberStr, 10, 64)
if err != nil {
client.Close()
dataScanClient.Close()
dataProductClient.Close()
projectsClient.Close()
return nil, fmt.Errorf("failed to parse project number %q as int64: %w", projectNumberStr, err)
}
s := &Source{
Config: r,
Client: client,
DataScanClient: dataScanClient,
dataProductClient: dataProductClient,
projectsClient: projectsClient,
projectNumber: projectNumber,
}
return s, nil
}
var _ sources.Source = &Source{}
type Source struct {
ConfigView on GitHub (pinned to 8cc6e09de2)
Solutions
- Confirm GetProject is hitting the real Google API (remove mocks/proxies that may return `projects/<project-id>` instead of `projects/<number>`).
- Retry initialization to rule out a transient malformed response.
- Update cloud.google.com/go/resourcemanager to the latest version and file an issue with Google if the real API returns a non-numeric second segment.
Defensive patterns
Strategy: try-catch
Try / catch
src, err := cfg.Initialize(ctx, tracer)
if err != nil {
if strings.Contains(err.Error(), "failed to parse project number") {
log.Printf("unexpected project number from API; retrying: %v", err)
return cfg.Initialize(ctx, tracer)
}
return err
} Prevention
- Do not route Resource Manager traffic through custom transforms/mocks.
- Keep dependencies updated so GetProject returns the canonical `projects/<number>` name.
- Treat recurrence as an upstream bug and report to the library maintainers.
When it happens
Trigger: Initialize runs strconv.ParseInt(projectNumberStr, 10, 64) on parts[1] of proj.Name and the string is not a decimal integer (e.g. an alphanumeric project ID was returned instead of a numeric project number).
Common situations: Custom/mock Resource Manager endpoints returning the project ID rather than the number in the resource name; altered or proxied API responses; corrupted service responses.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- unexpected project resource name format: %q
- failed to get project details for project %q: %w
- failed to find default Google Cloud credentials for project
- failed to create Dataplex client for project %q: %w
- failed to create Dataplex DataScan client for project %q: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/a4c2a2ea6e194a63.
Report an issue: GitHub.