{"record":{"id":"f395d0ed2e4aa5b8","repo":"hashicorp/nomad","slug":"could-not-assign-executor-to-windows-job-object","errorCode":null,"errorMessage":"could not assign executor to Windows job object: %w","messagePattern":"could not assign executor to Windows job object: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"drivers/shared/executor/executor_windows.go","lineNumber":148,"sourceCode":"\n\tinfo := windows.JOBOBJECT_EXTENDED_LIMIT_INFORMATION{\n\t\tBasicLimitInformation: windows.JOBOBJECT_BASIC_LIMIT_INFORMATION{\n\t\t\tLimitFlags: windows.JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE,\n\t\t},\n\t}\n\t_, err = windows.SetInformationJobObject(\n\t\tjob,\n\t\twindows.JobObjectExtendedLimitInformation,\n\t\tuintptr(unsafe.Pointer(&info)),\n\t\tuint32(unsafe.Sizeof(info)))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not configure Windows job object for executor: %w\", err)\n\t}\n\n\thandle := windows.CurrentProcess()\n\terr = windows.AssignProcessToJobObject(job, handle)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not assign executor to Windows job object: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// Cleanup any still hanging user processes\nfunc (e *UniversalExecutor) killProcessTree(proc *os.Process) error {\n\t// We must first verify if the process is still running.\n\t// (Windows process often lingered around after being reported as killed).\n\thandle, err := syscall.OpenProcess(syscall.PROCESS_TERMINATE|syscall.SYNCHRONIZE|syscall.PROCESS_QUERY_INFORMATION, false, uint32(proc.Pid))\n\tif err != nil {\n\t\treturn os.NewSyscallError(\"OpenProcess\", err)\n\t}\n\tdefer syscall.CloseHandle(handle)\n\n\tresult, err := syscall.WaitForSingleObject(syscall.Handle(handle), 0)\n\n\tswitch result {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_windows.go#L130-L166","documentation":"This error wraps the failure of windows.AssignProcessToJobObject when the Nomad executor tries to attach its newly created process to a Windows Job Object. Job Objects are how Nomad tracks and cleans up all child processes of a task on Windows. If assignment fails, the executor cannot guarantee process-tree cleanup, so it aborts startup.","triggerScenarios":"Calling setNewProcessGroup during executor launch when the OS refuses to assign the current process handle to the job object — e.g. invalid/closed job handle, insufficient privileges, or the process already belongs to a job that disallows reassignment (nested job limitations on older Windows).","commonSituations":"Running Nomad on constrained Windows environments (containers, older Windows builds without nested job support), running the agent under a security policy that restricts job object usage, or a prior CloseHandle on the job object.","solutions":["Verify the Windows version supports nested job objects (Windows 8/Server 2012+); upgrade the host OS","Ensure the Nomad agent runs with sufficient privileges (not a heavily restricted service account)","Check the preceding 'could not configure Windows job object' path for CreateJobObject failures and fix that first","Run Nomad outside restrictive container/sandbox layers that already place the process in an incompatible job"],"exampleFix":"// before\nif err := windows.AssignProcessToJobObject(job, handle); err != nil { /* startup fails here */ }\n// after\n// run Nomad agent as a normal service on Windows Server 2016+ so job assignment succeeds","handlingStrategy":"try-catch","validationCode":"if runtime.GOOS == \"windows\" && (win32build < win8) { /* upgrade OS before running nomad agent */ }","typeGuard":null,"tryCatchPattern":"if err := startTask(); err != nil {\n    if strings.Contains(err.Error(), \"could not assign executor to Windows job object\") {\n        // surface host OS / privilege guidance to operator\n    }\n}","preventionTips":["Run Nomad on Windows Server 2012+ where nested jobs are supported","Run the agent under an account without restrictive job-object policies","Keep the job-object setup path (previous error) healthy first"],"tags":["windows","process-management","job-object"],"backgroundTag":"windows-job-object-assignment-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"}