KEMBAR78
Fix `hasActionsWorkflows` throwing an exception if the workflows folder doesn't exist by mbg · Pull Request #3084 · github/codeql-action · GitHub
Skip to content

Conversation

@mbg
Copy link
Member

@mbg mbg commented Sep 5, 2025

This problem was introduced in #3009 since lstatSync throws an exception by default if the filesystem object doesn't exist.

We likely didn't come across this because it requires both of the following conditions to hold:

  • There is no .github/workflows folder
  • And there is no input to languages

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.

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.

@mbg mbg requested a review from a team as a code owner September 5, 2025 20:14
@Copilot Copilot AI review requested due to automatic review settings September 5, 2025 20:14
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 fixes a bug where the hasActionsWorkflows function would throw an exception when the .github/workflows folder doesn't exist. The fix uses the throwIfNoEntry: false option in fs.lstatSync to return undefined instead of throwing when the path doesn't exist.

  • Updated fs.lstatSync to use { throwIfNoEntry: false } option to handle non-existent directories gracefully
  • Added a test case to verify the function doesn't throw when the workflows folder is missing

Reviewed Changes

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

File Description
src/config-utils.ts Fixed hasActionsWorkflows to handle missing workflows directory without throwing
src/config-utils.test.ts Added test to verify the function handles missing workflows folder gracefully
lib/init-action.js Generated JavaScript file (not reviewed per guidelines)

@mbg mbg merged commit 144880b into main Sep 8, 2025
278 checks passed
@mbg mbg deleted the mbg/fix/hasActionsWorkflows branch September 8, 2025 08:54
@github-actions github-actions bot mentioned this pull request Sep 9, 2025
8 tasks
Copy link

@krsjenswbp krsjenswbp left a comment

Choose a reason for hiding this comment

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

merge

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants