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 nilView on GitHub (pinned to 482b49bf1a)
Solutions
- Fix the config per the appended diagnostics: correct types, remove unknown keys, fix HCL syntax
- Check the plugin's documentation for its expected config schema
- 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
- Match plugin config exactly to the plugin's documented schema
- Type-check values (booleans vs strings) in client config
- After plugin upgrades, re-validate existing config stanzas
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
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to convert HCL schema:
- only one storage block is allowed
- Error loading %s: %s
- failed to decode HCL file %s: %w
- failed to parse HCL file %s: %w
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/95e74cdd44b45007.
Report an issue: GitHub.