Skip to content

Explain how to override language autodetection in CodeQL errors - #4335

Open
therealsamyak wants to merge 10000 commits into
github:mainfrom
therealsamyak:fix/4334-skip-languages-without-files
Open

therealsamyak wants to merge 10000 commits into
github:mainfrom
therealsamyak:fix/4334-skip-languages-without-files

Conversation

@therealsamyak

@therealsamyak therealsamyak commented Nov 19, 2026 •

Copy link
Copy Markdown

Related to #4334.

The GitHub languages API describes the default branch. Automatic language detection can therefore select a language that is absent from the checkout.

When CodeQL reports that it saw no source code, the Action preserves the original error. It adds guidance to set the languages input on init if automatic detection selected a language that is absent. A no-source error can also indicate an extraction or build problem. In CodeQL CLI 2.27.5, an absent JavaScript source and a malformed .xsjs file can produce the same finalization error.

This PR provides troubleshooting guidance for #4334. Automatic skipping requires CodeQL to distinguish missing sources from extraction failures.

Risk assessment

This change affects the text of no-source-code errors. Language selection and analysis behavior remain unchanged.

Which use cases does this change impact?

Code Scanning and Code Quality runs can see the additional guidance on github.com and GitHub Enterprise Server. Advanced setup workflows can use the languages input to select the languages to analyze.

How did/will you validate this change?

  • The exit-code-32 unit test verifies that the Action preserves the original diagnostic and adds the new guidance.
  • npm run build, npm run lint, and npm run test pass.
  • The change-note validator passes.

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

Revert the message change to restore the previous wording.

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

The guidance appears in the failed workflow's error message. The regression test checks that the error remains a configuration error.

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

No changes in other repositories are required for the guidance.

Merge / deployment checklist

  • Existing workflows retain the same language selection and failure behavior.
  • The change note is in unreleased-change-notes/no-source-code-language-guidance.md.
  • The guidance matches the existing troubleshooting documentation.

Michael B. Gale and others added 30 commits October 26, 2026 13:23
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Address `ubuntu-26.04`-related CI failures
Bumps the npm-minor group with 3 updates in the / directory: [js-yaml](https://github.com/nodeca/js-yaml), [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) and [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint).


Updates `js-yaml` from 5.4.3 to 5.5.0
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](nodeca/js-yaml@5.4.3...5.5.0)

Updates `eslint-plugin-jsdoc` from 65.3.4 to 65.3.15
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Commits](gajus/eslint-plugin-jsdoc@v65.3.4...v65.3.15)

Updates `typescript-eslint` from 8.71.2 to 8.72.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.72.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 5.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor
- dependency-name: eslint-plugin-jsdoc
  dependency-version: 65.3.15
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm-minor
- dependency-name: typescript-eslint
  dependency-version: 8.72.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps the actions-minor group with 1 update in the /.github/workflows directory: [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/download-artifact` from 8.0.1 to 8.0.2
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v8.0.1...9000827)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 8.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6.4.0 to 7.1.0.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@48b55a0...949feb2)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: 7.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…e-server-versions

Update supported GitHub Enterprise Server versions
…r-on-dequeue

Ping the user who enqueued a PR when it's removed from the merge queue
Bump `undici` override to the latest `7.x` version
Henry Mercer and others added 11 commits November 19, 2026 10:59
…overage

Test the runner images in a dedicated `runner-images` PR check
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…m-minor-04c9f5c560

Bump the npm-minor group across 1 directory with 9 updates
…st-xml-parser-5.12.1

Bump fast-xml-parser from 5.7.1 to 5.12.1
…r-comments-check

Exclude `Post PR comments` from required checks
…e-v2.27.5

Update default bundle to 2.27.5
Language autodetection uses the GitHub languages API. That API reports
the languages of the default branch, and GitHub updates the data in
the background. After the last file of a language is removed, the API
can still report that language. The Action then creates a database for
it, and `analyze` fails with exit code 32 because CodeQL sees no source
code.

When languages are autodetected, check the checkout for files with the
extensions that each extractor declares in its `codeql-extractor.yml`.
Skip a language if no such file exists, and log the reason. Ignore the
JavaScript extractor's `data` file type, because CodeQL does not count
`.json` or `.yml` files as JavaScript source. Languages from the
`languages` input are not changed.

Fixes github#4334
@therealsamyak
therealsamyak requested a review from a team as a code owner November 19, 2026 20:22
Copilot Bot adaptive review requested due to automatic review settings November 19, 2026 20:22

ghost 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.

🟡 Changes recommended

Autodetection can silently drop languages with build-generated or symlinked sources before tracing begins, leaving code unanalyzed.

3 open issues
What changed in this PR

Addresses #4334 by checking the checkout before selecting autodetected languages, reducing analysis failures caused by stale GitHub language statistics.

Changes:

  • Reads extractor file extensions and filters out autodetected languages without matching files, excluding JavaScript data-file types.
  • Preserves explicit language inputs and languages without declared file types.
  • Adds unit tests, a release note, and regenerated bundled JavaScript.
File Description
unreleased-change-notes/​skip-languages-without-files.md Documents the autodetection behavior change.
src/​languages/​source-files.ts Adds extractor metadata parsing and source-file filtering.
src/​languages/​source-files.test.ts Tests extension parsing, traversal, and filtering.
src/​config-utils.ts Applies source-file filtering to autodetected languages.
src/​config-utils.test.ts Tests autodetection filtering and explicit-input preservation.
lib/​entry-points.js Regenerated bundle containing the TypeScript changes.

Review effort: Balanced (adaptive)

Comment thread src/config-utils.ts Outdated
Comment on lines +293 to +295
if (autodetected) {
languages = filterLanguagesWithSourceFiles(
languages,
Comment thread src/languages/source-files.ts Outdated
): Set<string> {
const found = new Set<string>();
const pendingDirs = [rootDir];
while (pendingDirs.length > 0 && found.size < extensions.size) {
Comment thread src/languages/source-files.ts Outdated
if (entry.name !== ".git") {
pendingDirs.push(path.join(dir, entry.name));
}
} else if (entry.isFile()) {
@jketema

ghost commented Nov 20, 2026

Copy link
Copy Markdown

Hi @therealsamyak,

Although this looks nice in practice, this is not going to work - at least not without further changes - because for a number of the extractors file_types does not accurately reflect which files are being picked up upon. For example, our JavaScript tooling picks up on files with the .xsjs extension, while this extension is not mentioned in JavaScript's codeql-extractor.yml.

The previous fix filtered autodetected languages in init by matching
the extensions in each extractor's codeql-extractor.yml file_types.
That list is not complete. For example, the JavaScript extractor also
extracts .xsjs and .xsjslib files, so a repository with only such files
would lose JavaScript analysis. The pre-build check also missed sources
that the build generates, and it walked the whole checkout.

Use CodeQL's own result instead. When database finalization fails with
the no-source-code-seen error (exit code 32) for an autodetected
language that CodeQL extracts by reading the checkout, analyze now
skips that language with a warning and analyzes the others. Languages
from the languages input and traced languages still fail, because for
them the error usually means a build or configuration problem. If no
autodetected language has source code, analyze still fails.

To support this, init saves whether it autodetected the languages in
the new languagesAutodetected config field, and
wrapCliConfigurationError returns a CliConfigurationError that keeps
the CLI error category.
@jketema

ghost commented Nov 20, 2026 •

Copy link
Copy Markdown

The updated change is also not correct, as CodeQL might not have been able to detect code for other reasons, e.g., a compiler version mismatch. That then is actually an issue with CodeQL that will need to be fixed there.

@therealsamyak therealsamyak changed the title Skip autodetected languages with no source files Skip autodetected languages that CodeQL sees no source code for Nov 20, 2026
therealsamyak added 2 commits November 20, 2026 04:22
Keep CodeQL finalization failures visible. A no-source error can
also indicate a compiler or extractor failure, so it cannot justify
skipping analysis.

Point users to the init languages input when automatic detection
selects a language that is absent from the checkout.
Bring in the latest release mergeback and verify the generated
bundle against the current base.
@therealsamyak therealsamyak changed the title Skip autodetected languages that CodeQL sees no source code for Explain how to override language autodetection in CodeQL errors Nov 20, 2026
@therealsamyak
therealsamyak force-pushed the fix/4334-skip-languages-without-files branch from 9db04fe to d0be3c6 Compare November 26, 2026 02:22

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants