{"record":{"id":"77697c59b5225057","repo":"googleapis/mcp-toolbox","slug":"unexpected-project-resource-name-format-q","errorCode":null,"errorMessage":"unexpected project resource name format: %q","messagePattern":"unexpected project resource name format: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dataplex/dataplex.go","lineNumber":107,"sourceCode":"\n\t// Resolve project number\n\tproj, err := projectsClient.GetProject(ctx, &resourcemanagerpb.GetProjectRequest{\n\t\tName: \"projects/\" + r.Project,\n\t})\n\tif err != nil {\n\t\tclient.Close()\n\t\tdataScanClient.Close()\n\t\tdataProductClient.Close()\n\t\tprojectsClient.Close()\n\t\treturn nil, fmt.Errorf(\"failed to get project details for project %q: %w\", r.Project, err)\n\t}\n\tparts := strings.Split(proj.Name, \"/\")\n\tif len(parts) < 2 {\n\t\tclient.Close()\n\t\tdataScanClient.Close()\n\t\tdataProductClient.Close()\n\t\tprojectsClient.Close()\n\t\treturn nil, fmt.Errorf(\"unexpected project resource name format: %q\", proj.Name)\n\t}\n\tprojectNumberStr := parts[1]\n\tprojectNumber, err := strconv.ParseInt(projectNumberStr, 10, 64)\n\tif err != nil {\n\t\tclient.Close()\n\t\tdataScanClient.Close()\n\t\tdataProductClient.Close()\n\t\tprojectsClient.Close()\n\t\treturn nil, fmt.Errorf(\"failed to parse project number %q as int64: %w\", projectNumberStr, err)\n\t}\n\n\ts := &Source{\n\t\tConfig:            r,\n\t\tClient:            client,\n\t\tDataScanClient:    dataScanClient,\n\t\tdataProductClient: dataProductClient,\n\t\tprojectsClient:    projectsClient,\n\t\tprojectNumber:     projectNumber,","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dataplex/dataplex.go#L89-L125","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func validProjectResource(name string) bool {\n\tparts := strings.Split(name, \"/\")\n\treturn len(parts) >= 2 && parts[0] == \"projects\"\n}","tryCatchPattern":"src, err := cfg.Initialize(ctx, tracer)\nif err != nil {\n\tif strings.Contains(err.Error(), \"unexpected project resource name format\") {\n\t\tlog.Printf(\"Resource Manager returned malformed name; retrying: %v\", err)\n\t\treturn cfg.Initialize(ctx, tracer)\n\t}\n\treturn err\n}","preventionTips":["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."],"tags":["gcp","dataplex","parsing","initialization","defensive"],"backgroundTag":"unexpected-resource-name-format","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}