Skip to content

Report cancelled jobs with a separate job status in init-post - #4345

Draft
henrymercer wants to merge 1 commit into
mainfrom
henrymercer/cancelled-runs-reporting
Draft

henrymercer wants to merge 1 commit into
mainfrom
henrymercer/cancelled-runs-reporting

Conversation

@henrymercer

Copy link
Copy Markdown
Contributor

The init post step reports jobs that were cancelled before the analysis completed as JOB_STATUS_UNKNOWN if init hadn't saved a configuration, and as JOB_STATUS_CONFIGURATION_ERROR if it had. This makes both statuses noisy, for example when concurrency groups cancel superseded runs. The post step already receives job.status through the internal job-status input, so this uses it to report these jobs as JOB_STATUS_CANCELLED instead. A job that was cancelled after the analysis completed is still reported as a success, and a job where a CodeQL Action step reported an error before the cancellation still reports that error.

The status report API rejects job statuses it doesn't recognise, so we only send the new status to github.com and GHE.com, and GHES keeps reporting these jobs as before. Job-level timeouts also reach the post step as cancellations, so they're reported as cancelled too.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Which use cases does this change impact?

Workflow types:

  • Advanced setup - Impacts users who have custom CodeQL workflows.
  • Managed - Impacts users with dynamic workflows (Default Setup, Code Quality, ...).

Products:

  • Code Scanning - The changes impact analyses when analysis-kinds: code-scanning.
  • Code Quality - The changes impact analyses when analysis-kinds: code-quality.
  • Other first-party - The changes impact other first-party analyses.

Environments:

  • Dotcom - Impacts CodeQL workflows on github.com and/or GitHub Enterprise Cloud with Data Residency.

How did/will you validate this change?

  • Test repository - This change will be tested on a test repository before merging, specifically to confirm that the init-post status report for a cancelled run is accepted.
  • Unit tests - I am depending on unit test coverage (i.e. tests in .test.ts files).
  • End-to-end tests - I am depending on PR checks (i.e. tests in pr-checks).

If something goes wrong after this change is released, what are the mitigation and rollback strategies?

  • Rollback - Change can only be disabled by rolling back the release or releasing a new version with a fix.

How will you know if something goes wrong after this change is released?

  • Telemetry - I rely on existing telemetry or have made changes to the telemetry.

Are there any special considerations for merging or releasing this change?

  • Special considerations - This change should only be merged once github.com and GHE.com support JOB_STATUS_CANCELLED in status reports. Otherwise, we'd lose the init-post status reports for cancelled jobs, though workflows wouldn't be affected.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change. Not added, since this only changes telemetry.
  • Confirm the readme and docs have been updated if necessary.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 19:56
@github-actions github-actions Bot added the size/M Should be of average difficulty to review label Nov 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human confirmation that github.com and GHE.com accept the ungated JOB_STATUS_CANCELLED API value is needed, since local unit tests cannot establish server compatibility and rejection would drop cancelled-job reports.

No open issues 🎉

1 file not reviewed
What changed in this PR

This PR makes cancellation telemetry more precise by reporting unfinished, cancelled CodeQL jobs separately from unknown statuses and configuration errors.

Changes:

  • Adds JOB_STATUS_CANCELLED for github.com and GHE.com, while preserving existing GHES behavior.
  • Preserves successful analysis results and previously reported CodeQL errors when a job is later cancelled.
  • Adds unit tests for cancellation timing, status precedence, and platform compatibility.
File Description
src/​status-report.ts Defines the cancelled status, display name, and platform support check.
src/​init-action-post.ts Uses the runtime job status to classify cancellations in post-step reporting.
src/​init-action-post.test.ts Tests cancellation reporting, status precedence, and GHES fallback behavior.

Review effort: Balanced (adaptive)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Should be of average difficulty to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants