hashicorp/nomad · warning

GCE machine-type format invalid: %s

Error message

GCE machine-type format invalid: %s

What it means

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.

Source

Thrown at client/fingerprint/env_gce.go:303

	return nil
}

func (f *EnvGCEFingerprint) gceProbe() error {
	// TODO: better way to detect GCE?

	// Query the metadata url for the machine type, to verify we're on GCE.
	machineType, err := f.Get("machine-type", false)
	if err != nil {
		return err
	}

	match, err := regexp.MatchString("projects/.+/machineTypes/.+", machineType)
	if err != nil {
		return err
	}

	if !match {
		return fmt.Errorf("GCE machine-type format invalid: %s", machineType)
	}

	return nil
}

// Reload is a no-op but implements ReloadableFingerprint
func (f *EnvGCEFingerprint) Reload() {}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check what curl -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/machine-type returns
  2. If running on non-GCE infrastructure, disable the gce fingerprint
  3. Upgrade Nomad — newer versions may accept short-form machine types
  4. Report/patch the probe if your environment legitimately returns a different but valid format

Example fix

// before: short form fails validation
machineType = "n1-standard-1"
// after: expected full URI
machineType = "projects/my-project/zones/us-central1-a/machineTypes/n1-standard-1"
Defensive patterns

Strategy: validation

Validate before calling

var machineTypePattern = regexp.MustCompile(`^projects/.+/machineTypes/.+$`)
func validMachineType(mt string) bool { return machineTypePattern.MatchString(mt) }

Type guard

func isFullMachineTypeURI(mt string) bool { return mt != "" && strings.HasPrefix(mt, "projects/") && strings.Contains(mt, "/machineTypes/") }

Try / catch

if err := gceProbe(ctx, client); err != nil {
    var fmtErr *fmt.Errorf
    if strings.Contains(err.Error(), "machine-type format invalid") { log.Printf("nonstandard GCE metadata: %v", err) }
    return err
}

Prevention

When it happens

Trigger: Metadata server returned a short-form machine type (e.g. "n1-standard-1") instead of the full path, or the value is empty/garbage.

Common situations: Custom/alternative GCE-compatible environments (e.g. GCE-like clouds) returning different machine-type formats; metadata API version changes; spoofed or overridden metadata endpoints.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/49d1f098702195a2. Report an issue: GitHub.