hashicorp/nomad · error

failed to parse config:

Error message

failed to parse config: 

What it means

In plugins/shared/cmd/launcher/command/device.go:198 (setConfig, called by Run), after obtaining the schema the launcher parses the submitted plugin configuration (hclutils.ParseHclInterface). If HCL diagnostics have errors, it returns multierror with the prefix 'failed to parse config: ' plus each parse error. It means the user-supplied device plugin config does not conform to the plugin's declared schema.

Source

Thrown at plugins/shared/cmd/launcher/command/device.go:198

		for _, err := range diag.Errs() {
			errStr = fmt.Sprintf("%s\n* %s", errStr, err.Error())
		}
		return nil, errors.New(errStr)
	}

	return schema, nil
}

func (c *Device) setConfig(spec hcldec.Spec, apiVersion string, config []byte, nmdCfg *base.AgentConfig) error {
	// Parse the config into hcl
	configVal, err := hclConfigToAny(config)
	if err != nil {
		return err
	}

	val, diag, diagErrs := hclutils.ParseHclInterface(configVal, spec, nil)
	if diag.HasErrors() {
		return multierror.Append(errors.New("failed to parse config: "), diagErrs...)
	}

	cdata, err := msgpack.Marshal(val, val.Type())
	if err != nil {
		return err
	}

	req := &base.Config{
		PluginConfig: cdata,
		AgentConfig:  nmdCfg,
		ApiVersion:   apiVersion,
	}

	if err := c.dev.SetConfig(req); err != nil {
		return err
	}

	return nil

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Fix the config per the appended diagnostics: correct types, remove unknown keys, fix HCL syntax
  2. Check the plugin's documentation for its expected config schema
  3. Test the config against the plugin schema with nomad agent -config validation before startup

Example fix

// before
config {
  enabled = "yes"   # wrong type
  unknow_key = 1    # unknown attribute
}
// after
config {
  enabled = true
}
Defensive patterns

Strategy: validation

Validate before calling

// validate plugin config HCL against the schema before startup
val, diag, _ := hclutils.ParseHclInterface(cfg, spec, nil)
if diag.HasErrors() { return fmt.Errorf("config invalid: %v", diag.Errs()) }

Try / catch

if err := c.setConfig(spec, apiVer, cfg, agentCfg); err != nil {
    return fmt.Errorf("device plugin config rejected: %w", err)
}

Prevention

When it happens

Trigger: Providing a device plugin config block whose HCL fails to decode: wrong value types (string where number expected), unknown attributes not allowed by the schema, or malformed HCL syntax in the config blob passed to the launcher.

Common situations: Typo'd keys in plugin config stanzas in the Nomad client config; passing JSON-as-HCL with wrong types; version drift where a plugin expects new config fields and old configs reference removed ones.

Understand the failure class

Related errors


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