Skip to content

Break down overlay disabled reason#3538

Open
henrymercer wants to merge 5 commits intomainfrom
henrymercer/breakdown-overlay-disabled-reason
Open

Break down overlay disabled reason#3538
henrymercer wants to merge 5 commits intomainfrom
henrymercer/breakdown-overlay-disabled-reason

Conversation

@henrymercer
Copy link
Contributor

Break down the two most common categories to help us better understand why overlay isn't run.

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.

Environments:

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

How did/will you validate this change?

  • Unit tests - I am depending on unit test coverage (i.e. tests in .test.ts files).

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.
    • Dashboards - I will watch relevant dashboards for issues after the release. Consider whether this requires this change to be released at a particular time rather than as part of a regular release.
    • Alerts - New or existing monitors will trip if something goes wrong with this change.

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

  • No special considerations - This change can be merged at any time.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

@henrymercer henrymercer requested a review from a team as a code owner March 3, 2026 16:25
Copilot AI review requested due to automatic review settings March 3, 2026 16:25
@github-actions github-actions bot added the size/M Should be of average difficulty to review label Mar 3, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines overlay-analysis disablement reporting by splitting previously broad disablement categories into more specific OverlayDisabledReason values, primarily to improve telemetry and diagnostics around why overlay analysis doesn’t run.

Changes:

  • Expand OverlayDisabledReason to distinguish disk vs memory resource failures and feature-enablement sub-cases.
  • Refactor overlay enablement/resource checks to return a specific disablement reason (or undefined when enabled).
  • Update unit tests to expect the new disablement reasons.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/overlay/diagnostics.ts Extends OverlayDisabledReason with more granular reason values used for telemetry.
src/config-utils.ts Refactors overlay enablement/resource-check logic to return specific disablement reasons.
src/config-utils.test.ts Updates overlay mode tests to assert the new disablement reasons.
lib/init-action.js Generated output reflecting the TypeScript changes (not reviewed).

Copy link
Member

@mbg mbg left a comment

Choose a reason for hiding this comment

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

Thanks for working on this -- getting a more detailed reason for why overlay is disabled is useful!

That said, I am not overly fond of some of the details of the changes here, sorry! See my comments for the details.

* languages and configuration, returning the specific reason it is disabled,
* or `undefined` if it is enabled.
*/
async function getOverlayFeatureDisabledReason(
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is a good re-naming for this function. The function name should be focused on what the function does, but the new name suggests this is a getter which just retrieves some existing value. But the function actually performs the checks, and only returns the reason why overlay analysis is disabled if one of those checks is negative. I view it returning the reason why overlay is disabled as secondary.

The old name (isOverlayAnalysisFeatureEnabled) is better in this regard, but just isOverlayAnalysisEnabled would also be good. (Or indeed isOverlayAnalysisDisabled.)

More broadly, I wonder if I'd prefer a { enabled: true } | { enabled: false, reason: OverlayDisabledReason } kind of type for these things, rather than OverlayDisabledReason | undefined. I don't particularly like using undefined to indicate a successful outcome / the absence of a non-standard condition.

Comment on lines +30 to +31
* Overlay analysis is restricted to code-scanning-only configs but the config uses custom
* queries or packs, disables default queries, or specifies query filters.
Copy link
Member

Choose a reason for hiding this comment

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

I know you have already changed this in response to Copilot's comment, but a more significant issue with this comment is the ambiguity over whether it refers to:

  • analysis-kind: code-scanning, with no customisation; or
  • "code-scanning-only configs" is supposed to mean no query customisations.

I.e. it is not clear if "code-scanning-only configs" is about analysis kinds or not.

// if the default queries are not disabled, and no packs, queries, or
// query-filters are specified.
return (
const isCodeScanningOnly =
Copy link
Member

Choose a reason for hiding this comment

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

See my other comment, but I am concerned about the naming here / relationship with analysis kinds. Since we have a specific code-scanning analysis kind, it is confusing that this seems to mean "no customisation".

Comment on lines +762 to +768
async function getResourceDisabledReason(
codeql: CodeQL,
diskUsage: DiskUsage | undefined,
ramInput: string | undefined,
logger: Logger,
useV2ResourceChecks: boolean,
): Promise<boolean> {
): Promise<OverlayDisabledReason | undefined> {
Copy link
Member

Choose a reason for hiding this comment

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

Same comments as for getOverlayFeatureDisabledReason

Comment on lines +849 to +854
(disabledReason = await getOverlayFeatureDisabledReason(
features,
codeql,
languages,
codeScanningConfig,
)
)) === undefined
Copy link
Member

Choose a reason for hiding this comment

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

It would be good to move this assignment out of the condition.

Comment on lines +873 to +879
(resourceDisabledReason = await getResourceDisabledReason(
codeql,
diskUsage,
ramInput,
logger,
useV2ResourceChecks,
))
)) !== undefined
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

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.

3 participants