{"record":{"id":"49d1f098702195a2","repo":"hashicorp/nomad","slug":"gce-machine-type-format-invalid-s","errorCode":null,"errorMessage":"GCE machine-type format invalid: %s","messagePattern":"GCE machine-type format invalid: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"client/fingerprint/env_gce.go","lineNumber":303,"sourceCode":"\treturn nil\n}\n\nfunc (f *EnvGCEFingerprint) gceProbe() error {\n\t// TODO: better way to detect GCE?\n\n\t// Query the metadata url for the machine type, to verify we're on GCE.\n\tmachineType, err := f.Get(\"machine-type\", false)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmatch, err := regexp.MatchString(\"projects/.+/machineTypes/.+\", machineType)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !match {\n\t\treturn fmt.Errorf(\"GCE machine-type format invalid: %s\", machineType)\n\t}\n\n\treturn nil\n}\n\n// Reload is a no-op but implements ReloadableFingerprint\nfunc (f *EnvGCEFingerprint) Reload() {}\n","sourceCodeStart":285,"sourceCodeEnd":311,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/fingerprint/env_gce.go#L285-L311","documentation":"The GCE fingerprinter validates the machine-type value returned by the GCE metadata server, expecting the full URI form 'projects/<project>/machineTypes/<type>'. gceProbe runs regexp.MatchString on it; if the string doesn't match the expected format, this error is returned and GCE attributes are not set.","triggerScenarios":"Metadata server returned a short-form machine type (e.g. \"n1-standard-1\") instead of the full path, or the value is empty/garbage.","commonSituations":"Custom/alternative GCE-compatible environments (e.g. GCE-like clouds) returning different machine-type formats; metadata API version changes; spoofed or overridden metadata endpoints.","solutions":["Check what curl -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/machine-type returns","If running on non-GCE infrastructure, disable the gce fingerprint","Upgrade Nomad — newer versions may accept short-form machine types","Report/patch the probe if your environment legitimately returns a different but valid format"],"exampleFix":"// before: short form fails validation\nmachineType = \"n1-standard-1\"\n// after: expected full URI\nmachineType = \"projects/my-project/zones/us-central1-a/machineTypes/n1-standard-1\"","handlingStrategy":"validation","validationCode":"var machineTypePattern = regexp.MustCompile(`^projects/.+/machineTypes/.+$`)\nfunc validMachineType(mt string) bool { return machineTypePattern.MatchString(mt) }","typeGuard":"func isFullMachineTypeURI(mt string) bool { return mt != \"\" && strings.HasPrefix(mt, \"projects/\") && strings.Contains(mt, \"/machineTypes/\") }","tryCatchPattern":"if err := gceProbe(ctx, client); err != nil {\n    var fmtErr *fmt.Errorf\n    if strings.Contains(err.Error(), \"machine-type format invalid\") { log.Printf(\"nonstandard GCE metadata: %v\", err) }\n    return err\n}","preventionTips":["Verify machine-type metadata format with curl before deploying","Disable the gce fingerprint on GCE-compatible but non-GCE clouds","Keep Nomad updated for metadata format tolerance fixes"],"tags":["gce","metadata","validation"],"backgroundTag":"machine-type-format-invalid","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}