{"record":{"id":"c0c70f988025e74a","repo":"hashicorp/nomad","slug":"failed-to-decode-driver-config-v-c0c70f","errorCode":null,"errorMessage":"failed to decode driver config: %v","messagePattern":"failed to decode driver config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/qemu/driver.go","lineNumber":464,"sourceCode":"\t\t\tif strings.HasPrefix(strings.TrimSpace(arg), \"-\") {\n\t\t\t\tif _, ok := allowed[arg]; !ok {\n\t\t\t\t\treturn fmt.Errorf(\"%q is not in args_allowlist\", arg)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error) {\n\tif _, ok := d.tasks.Get(cfg.ID); ok {\n\t\treturn nil, nil, fmt.Errorf(\"taskConfig with ID '%s' already started\", cfg.ID)\n\t}\n\n\tvar driverConfig TaskConfig\n\n\tif err := cfg.DecodeDriverConfig(&driverConfig); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to decode driver config: %v\", err)\n\t}\n\n\t// ensure that PortMap variables are populated early on\n\tcfg.Env = taskenv.SetPortMapEnvs(cfg.Env, driverConfig.PortMap)\n\n\thandle := drivers.NewTaskHandle(taskHandleVersion)\n\thandle.Config = cfg\n\n\tif err := validateEmulator(driverConfig.Emulator, d.config.EmulatorsAllowList); err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tif err := validateArgs(d.config.ArgsAllowList, driverConfig.Args); err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// Get the image source\n\tvmPath := driverConfig.ImagePath","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/qemu/driver.go#L446-L482","documentation":"StartTask decodes the task's driver-specific configuration block into the driver's TaskConfig struct via cfg.DecodeDriverConfig. This error wraps whatever decoding failure occurred (unknown fields, type mismatches, malformed HCL/JSON in the job's config stanza).","triggerScenarios":"StartTask when the job's task config stanza cannot be decoded into qemu TaskConfig — e.g. a field with the wrong type (string where int expected), an unrecognized key under the qemu driver config, or a malformed value.","commonSituations":"Job spec renames or typos a qemu config field (e.g. 'image_path' misspelled); passing a non-string where the schema expects one; upgrading Nomad so previously tolerated fields become rejected; copy-pasting config from another driver.","solutions":["Inspect the wrapped %v detail in the error message to identify the offending field, then fix the key name or value type in the job's config block.","Validate the job with 'nomad job validate' before submitting to catch decode errors early.","Align the config with the current qemu driver schema for your Nomad version (docs: drivers/qemu)."],"exampleFix":"// before (wrong type)\nconfig { image_path = \"...\" memory = \"1024\" } // memory not a TaskConfig field\n// after\nconfig { image_path = \"...\" }","handlingStrategy":"validation","validationCode":"var probe map[string]interface{}\nif err := hclDecodeInto(&probe, rawConfig); err != nil {\n    return fmt.Errorf(\"malformed qemu config block: %w\", err)\n}\n// check required keys/types before calling StartTask","typeGuard":null,"tryCatchPattern":"_, _, err := d.StartTask(cfg)\nif err != nil && strings.Contains(err.Error(), \"failed to decode driver config\") {\n    return fmt.Errorf(\"check the task's qemu config block against driver schema: %w\", err)\n}","preventionTips":["Run 'nomad job validate' on every job before submit","Keep job config keys matching the driver struct tags (mapstructure names)","Pin Nomad versions in CI so schema changes are caught","Avoid copy-pasting config blocks from other drivers"],"tags":["qemu","nomad","config-decode","job-spec"],"backgroundTag":"config-decode-failed","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"}