{"record":{"id":"3d51d64393a96d16","repo":"hashicorp/nomad","slug":"failed-to-encode-driver-config-v","errorCode":null,"errorMessage":"failed to encode driver config: %v","messagePattern":"failed to encode driver config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/taskrunner/task_runner.go","lineNumber":951,"sourceCode":"\n\t\t\tif tr.logger.IsTrace() {\n\t\t\t\t// Verbosely log every diagnostic for debugging\n\t\t\t\ttr.logger.Trace(\"error building environment variables\", \"key\", k, \"error\", err)\n\t\t\t}\n\t\t}\n\n\t\ttr.logger.Warn(\"some environment variables not available for rendering\", \"keys\", strings.Join(keys, \", \"))\n\t}\n\n\tval, diag, diagErrs := hclutils.ParseHclInterface(tr.task.Config, tr.taskSchema, vars)\n\tif diag.HasErrors() {\n\t\tparseErr := multierror.Append(errors.New(\"failed to parse config: \"), diagErrs...)\n\t\ttr.EmitEvent(structs.NewTaskEvent(structs.TaskFailedValidation).SetValidationError(parseErr))\n\t\treturn parseErr\n\t}\n\n\tif err := taskConfig.EncodeDriverConfig(val); err != nil {\n\t\tencodeErr := fmt.Errorf(\"failed to encode driver config: %v\", err)\n\t\ttr.EmitEvent(structs.NewTaskEvent(structs.TaskFailedValidation).SetValidationError(encodeErr))\n\t\treturn encodeErr\n\t}\n\n\t// If there's already a task handle (eg from a Restore) there's nothing\n\t// to do except update state.\n\tif tr.getDriverHandle() != nil {\n\t\t// Ensure running state is persisted but do *not* append a new\n\t\t// task event as restoring is a client event and not relevant\n\t\t// to a task's lifecycle.\n\t\tif err := tr.updateStateImpl(structs.TaskStateRunning); err != nil {\n\t\t\t//TODO return error and destroy task to avoid an orphaned task?\n\t\t\ttr.logger.Warn(\"error persisting task state\", \"error\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\t// Start the job if there's no existing handle (or if RecoverTask failed)","sourceCodeStart":933,"sourceCodeEnd":969,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/taskrunner/task_runner.go#L933-L969","documentation":"runDriver: after successfully parsing the task's HCL config, taskConfig.EncodeDriverConfig failed converting the parsed values into the driver's protobuf config (type mismatch between task config block and driver schema); the task fails validation and the driver never starts.","triggerScenarios":"Thrown at client/allocrunner/taskrunner/task_runner.go:951 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the driver config block in the job spec against the driver's schema","Verify driver plugin version matches expected config fields","Look for wrong-typed values (string vs number) in the task config"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}