Skip to content

[BUG]: Run --once fails to run at all when error happens during job scheduling #5290

@ChristoWolf

Description

@ChristoWolf

What happened?

Hi!

The issue(s)

The issue seems to be twofold:
When running an agent --once and an error happens (or at least a specific one mentioned in a bit), the agent fails to execute the job at all, even though it seems to be re-scheduled.

This is the error that makes the first job scheduling fail, for which I have no idea how it is caused.
It only happens sometimes, so it's kinda hard to reproduce currently to get more information:

[2025-08-11 09:12:39Z ERR  VisualStudioServices] PATCH request to https://<redacted>/_apis/distributedtask/pools/5/jobrequests/1037133 failed. HTTP Status: BadRequest

The agent's stdout then contains an error entry which refers to the agent log.

How this affects me:

I am using the run --once functionality together with a customized RunAgent.cmd startup script, namely

call C:\agent\run.cmd" --startuptype autostartup --once
shutdown /p /f

i.e. when the job has run, the agent will shut down.

However, with the mentioned issue, this leads to the following when it happens:

  1. The failing job scheduling leads to the error information (which points to the agent log) being written.
  2. The job seems to get scheduled again.
  3. Still, the machine shuts down, making the job fail.

Observations

  • It looks to me like the retry to schedule the job does not count as the once run, although it should.
  • No clue why all of the sudden I frequently get the PATCH request error, this hasn't happened at all a week or so ago.

Versions

  • Version Azure DevOps Server 2022.2 (AzureDevopsServer_20250527.1)
  • Agent 4.253.0
  • Windows 11 Version 24H2 (0S Build 26100.1742)

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

Azure DevOps Server (Please specify exact version in the textbox below)

Azure DevOps Server Version (if applicable)

Azure DevOps Server 2022.2

Operation system

Windows 11

Version controll system

Git

Relevant log output

[2025-08-11 09:12:39Z ERR  VisualStudioServices] PATCH request to https://<redacted>/_apis/distributedtask/pools/5/jobrequests/1037133 failed. HTTP Status: BadRequest

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions