googleapis/mcp-toolbox · error
unexpected project resource name format: %q
Error message
unexpected project resource name format: %q
What it means
After GetProject succeeds, the source splits the returned resource name (expected format `projects/<number>`) on '/' and requires at least two segments to extract the project number. This error is thrown when the API returns a project resource whose Name does not match that expected shape. It is a defensive parse guard and should be virtually impossible with a well-behaved Resource Manager API.
Source
Thrown at internal/sources/dataplex/dataplex.go:107
// Resolve project number
proj, err := projectsClient.GetProject(ctx, &resourcemanagerpb.GetProjectRequest{
Name: "projects/" + r.Project,
})
if err != nil {
client.Close()
dataScanClient.Close()
dataProductClient.Close()
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,View on GitHub (pinned to 8cc6e09de2)
Solutions
- Retry initialization — this is usually a malformed API response, so a transient issue or proxy problem.
- Remove any proxy/interceptor (VPC-SC gateways, mock servers) that could alter the Resource Manager response body.
- Check the version of cloud.google.com/go/resourcemanager and update to latest; report to Google if a real GetProject response lacks `projects/<id>` name format.
Defensive patterns
Strategy: try-catch
Type guard
func validProjectResource(name string) bool {
parts := strings.Split(name, "/")
return len(parts) >= 2 && parts[0] == "projects"
} Try / catch
src, err := cfg.Initialize(ctx, tracer)
if err != nil {
if strings.Contains(err.Error(), "unexpected project resource name format") {
log.Printf("Resource Manager returned malformed name; retrying: %v", err)
return cfg.Initialize(ctx, tracer)
}
return err
} Prevention
- Avoid proxies/mocks between the toolbox and the Resource Manager API.
- Keep cloud.google.com/go/resourcemanager up to date.
- Retry initialization once on this error; treat repeated occurrences as an upstream API bug.
When it happens
Trigger: Initialize parses proj.Name from GetProject; strings.Split yields fewer than 2 parts, e.g. proj.Name is empty or not in `projects/<number>` form.
Common situations: Mocked/stubbed Resource Manager servers or unusual API versions returning an atypical resource name; transient API behavior; custom proxies altering the response. Real users rarely hit this directly.
Related errors
- failed to parse project number %q as int64: %w
- 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/77697c59b5225057.
Report an issue: GitHub.