ansible/ansible · error · Win32Exception
QueryInformationJobObject() failed
Error message
QueryInformationJobObject() failed
What it means
Thrown by AsyncUtil.CanCreateBreakawayProcess when QueryInformationJobObject(JobObjectBasicLimitInformation) fails on the current job. After IsProcessInJob confirms the process is in a job, this query reads the job's limit flags to see whether JOB_OBJECT_LIMIT_BREAKAWAY_OK is set (i.e. children may escape the job). Failure means the flag query itself was rejected.
Source
Thrown at lib/ansible/module_utils/csharp/Ansible._Async.cs:283
{
throw new Win32Exception("IsProcessInJob() failed");
}
if (!isInJob)
{
return true;
}
NativeHelpers.JOBOBJECT_BASIC_LIMIT_INFORMATION jobInfo = new NativeHelpers.JOBOBJECT_BASIC_LIMIT_INFORMATION();
bool jobRes = NativeMethods.QueryInformationJobObject(
IntPtr.Zero,
NativeHelpers.JobObjectBasicLimitInformation,
ref jobInfo,
Marshal.SizeOf<NativeHelpers.JOBOBJECT_BASIC_LIMIT_INFORMATION>(),
IntPtr.Zero);
if (!jobRes)
{
throw new Win32Exception("QueryInformationJobObject() failed");
}
return (jobInfo.LimitFlags & NativeHelpers.JOB_OBJECT_LIMIT_BREAKAWAY_OK) != 0;
}
public static ProcessInformation CreateAsyncProcess(
string applicationName,
string commandLine,
SafeHandle stdin,
SafeHandle stdout,
SafeHandle stderr,
SafeHandle mutexHandle,
SafeHandle parentProcess,
StreamReader stdoutReader,
StreamReader stderrReader)
{
StringBuilder commandLineBuffer = new StringBuilder(commandLine);
int creationFlags = NativeHelpers.CREATE_NEW_CONSOLE |View on GitHub (pinned to 9cf16a4aca)
Solutions
- Check the Win32ErrorCode: 5 suggests the containing job denies query access to your token.
- Run the module/connection outside the restrictive job (e.g. interactive session instead of a hardened service) to confirm.
- Ensure the async wrapper configuration does not require breakaway when the job forbids it (parentProcess-based spawning is the fallback path).
- Report upstream with OS version if breakaway-eligible jobs still fail the query.
Defensive patterns
Strategy: try-catch
Try / catch
try
{
ok = AsyncUtil.CanCreateBreakawayProcess();
}
catch (Win32Exception ex) when (ex.Message.Contains("QueryInformationJobObject"))
{
// containing job denies the query (often access denied) or nested-job edge case;
// safest fallback: assume breakaway is NOT allowed and spawn under a parent process
ok = false;
} Prevention
- When the connection runs under a scheduler/service job, prefer parent-process-based async spawning over breakaway.
- Check job ACLs if you control the job object; grant query rights to the module's token.
- Cache the result once per run instead of probing repeatedly.
When it happens
Trigger: Passing a NULL job handle (as done here) queries the assigned job, which fails with ERROR_ACCESS_DENIED if the job handle is not queryable by the caller; nested-job configurations on older Windows versions (pre-Win8 nested-job semantics); a job that was terminated concurrently.
Common situations: Ansible connections running inside scheduler/service job objects (SCM, Task Scheduler, CI agents) whose ACLs deny query rights to the module's token; Windows versions with partial nested-job support.
Related errors
- IsProcessInJob() failed
- CreateProcessW() failed
- SearchPathW({0}) failed to get buffer length
- OpenProcess() failed
- CreateFileW({0}) failed 0x{1:X8}: {2}
AI-assisted analysis of ansible/ansible@9cf16a4aca (2026-08-15).
Data as JSON: /api/errors/08231baf2f38a80e.
Report an issue: GitHub.