{"record":{"id":"2437c07365fe8198","repo":"googleapis/mcp-toolbox","slug":"vm-q-not-found-in-project-q","errorCode":null,"errorMessage":"VM %q not found in project %q","messagePattern":"VM %q not found in project %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/cloudsqlconnect/gce.go","lineNumber":188,"sourceCode":"\t\t\t\tif instance.Name != vmName {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfoundInstances = append(foundInstances, instance)\n\t\t\t\tfoundZones = append(foundZones, ExtractNetworkName(zone))\n\t\t\t\tif len(foundInstances) > 1 {\n\t\t\t\t\treturn stopPaging\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil && err != stopPaging {\n\t\treturn nil, \"\", fmt.Errorf(\"failed to search for VM: %w\", err)\n\t}\n\n\tswitch len(foundInstances) {\n\tcase 0:\n\t\treturn nil, \"\", fmt.Errorf(\"VM %q not found in project %q\", vmName, project)\n\tcase 1:\n\t\treturn foundInstances[0], foundZones[0], nil\n\tdefault:\n\t\treturn nil, \"\", fmt.Errorf(\"multiple VMs named %q found in zones: %v - please specify vm_zone parameter\", vmName, foundZones)\n\t}\n}\n\n// stringErr signals early termination from Pages without conflating with\n// real API errors. Unexported: only FindVM's Pages callback uses it.\ntype stringErr string\n\nfunc (e stringErr) Error() string { return string(e) }\n","sourceCodeStart":170,"sourceCodeEnd":201,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/util/cloudsqlconnect/gce.go#L170-L201","documentation":"FindVM in internal/util/cloudsqlconnect/gce.go pages through the GCE AggregatedList API looking for a Compute Engine VM by name within a project. When paging finishes and no instance with the requested name was found, it returns this error. It is a user-input/result mismatch, not an API failure — the search itself succeeded but returned zero matches.","triggerScenarios":"Calling FindVM (via a tool's Invoke) with a vm_name that does not exist in the given GCP project, a typo'd VM name, a name from a different project, or a deleted VM.","commonSituations":"Developer pasted an instance name from another project or environment (staging vs prod); the VM was decommissioned; the name was copied with extra whitespace or wrong casing (GCE names are lowercase).","solutions":["Verify the VM name with `gcloud compute instances list --project=<project>` and correct the vm_name parameter","Confirm the project parameter matches the project that actually contains the VM","If the VM was deleted, recreate it or point the tool at an existing instance"],"exampleFix":"// before\nFindVM(ctx, \"my-Prod-VM\", \"my-project\", \"\")\n// after\nFindVM(ctx, \"my-prod-vm\", \"my-project\", \"\") // GCE names are lowercase; verify with gcloud compute instances list","handlingStrategy":"validation","validationCode":"vmName := params[\"vm_name\"]\nif vmName == \"\" || !regexp.MustCompile(`^[a-z]([-a-z0-9]{0,61}[a-z0-9])?$`).MatchString(vmName) {\n    return fmt.Errorf(\"vm_name %q is not a valid GCE instance name\", vmName)\n}","typeGuard":"func isValidGCEName(name string) bool {\n    return regexp.MustCompile(`^[a-z]([-a-z0-9]{0,61}[a-z0-9])?$`).MatchString(name)\n}","tryCatchPattern":"inst, zone, err := FindVM(ctx, vmName, project, zoneParam)\nif err != nil {\n    if strings.Contains(err.Error(), \"not found in project\") {\n        // surface a helpful hint: list matching instances\n        return fmt.Errorf(\"VM %q not found; run 'gcloud compute instances list --filter=name=%s' to see available names\", vmName, vmName)\n    }\n    return err\n}","preventionTips":["Verify VM names with `gcloud compute instances list` before invoking the tool","Pass vm_zone proactively to narrow the search scope","Use one source of truth (config/flag) for project and VM names to avoid cross-environment mixups"],"tags":["gcp","compute-engine","resource-not-found"],"backgroundTag":"resource-not-found","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"}