{"record":{"id":"f28bf0bc3886d3fa","repo":"hashicorp/nomad","slug":"failed-to-build-reattachconfig-from-taskconfig-sta","errorCode":null,"errorMessage":"failed to build ReattachConfig from taskConfig state: %v","messagePattern":"failed to build ReattachConfig from taskConfig state: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/java/driver.go","lineNumber":401,"sourceCode":"\t// If already attached to handle there's nothing to recover.\n\tif _, ok := d.tasks.Get(handle.Config.ID); ok {\n\t\td.logger.Debug(\"nothing to recover; task already exists\",\n\t\t\t\"task_id\", handle.Config.ID,\n\t\t\t\"task_name\", handle.Config.Name,\n\t\t)\n\t\treturn nil\n\t}\n\n\tvar taskState TaskState\n\tif err := handle.GetDriverState(&taskState); err != nil {\n\t\td.logger.Error(\"failed to decode taskConfig state from handle\", \"error\", err, \"task_id\", handle.Config.ID)\n\t\treturn fmt.Errorf(\"failed to decode taskConfig state from handle: %v\", err)\n\t}\n\n\tplugRC, err := pstructs.ReattachConfigToGoPlugin(taskState.ReattachConfig)\n\tif err != nil {\n\t\td.logger.Error(\"failed to build ReattachConfig from taskConfig state\", \"error\", err, \"task_id\", handle.Config.ID)\n\t\treturn fmt.Errorf(\"failed to build ReattachConfig from taskConfig state: %v\", err)\n\t}\n\n\texecImpl, pluginClient, err := executor.ReattachToExecutor(\n\t\tplugRC,\n\t\td.logger.With(\"task_name\", handle.Config.Name, \"alloc_id\", handle.Config.AllocID),\n\t\td.nomadConfig.Topology.Compute(),\n\t)\n\n\tif err != nil {\n\t\td.logger.Error(\"failed to reattach to executor\", \"error\", err, \"task_id\", handle.Config.ID)\n\t\treturn fmt.Errorf(\"failed to reattach to executor: %v\", err)\n\t}\n\n\th := &taskHandle{\n\t\texec:         execImpl,\n\t\tpid:          taskState.Pid,\n\t\tpluginClient: pluginClient,\n\t\ttaskConfig:   taskState.TaskConfig,","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/java/driver.go#L383-L419","documentation":"This error is returned by RecoverTask when pstructs.ReattachConfigToGoPlugin cannot build a valid go-plugin ReattachConfig from the stored ReattachConfig in the task state. The stored config lacks required fields (protocol, address, PID, etc.) or uses an unsupported protocol version. Without a valid reattach config the driver cannot reconnect to the executor plugin.","triggerScenarios":"TaskState.ReattachConfig is nil or incomplete (e.g. state persisted before the executor plugin fully started), or the stored protocol/addr fields cannot be converted to a go-plugin client config.","commonSituations":"Recovering allocations right after an agent crash where reattach info was never fully written; plugin protocol version mismatches after Nomad upgrades; manual state edits.","solutions":["Stop and restart the affected allocation so a fresh executor is launched","Verify the Nomad agent and executor plugin versions match (no mixed-version cluster during rolling upgrade)","Check the client logs for the underlying ReattachConfigToGoPlugin error detail","Restore valid client state or clear the corrupted allocation state"],"exampleFix":"// remediation: recreate the allocation rather than reattach\n// nomad alloc stop <alloc_id> && nomad job eval <job_id>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := driver.RecoverTask(handle); err != nil {\n    if strings.Contains(err.Error(), \"failed to build ReattachConfig\") {\n        // recreate the allocation instead of reattaching\n        _ = client.Allocations().Stop(ctx, alloc, nil)\n    }\n}","preventionTips":["Keep Nomad agents and executors version-consistent across the cluster","Let the client fully start tasks before triggering agent restarts","Avoid manual edits to client state files","Watch rolling upgrades so old executors never hand state to new drivers"],"tags":["nomad","java-driver","recover-task","go-plugin","reattach"],"backgroundTag":"reattach-config-invalid","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"}