Subchapter 78.5
references/troubleshooting.mdMarkdown9 KBView on GitHub
Comprehensive guide for diagnosing and resolving CodeQL analysis errors, SARIF upload issues, and common configuration problems.
Cause: CodeQL extractor did not find any source files during database creation.
Solutions:
--source-root points to the correct directoryautobuild is detecting the correct build systemautobuild to manual build mode with explicit build commandsCause: autobuild could not detect or run the project’s build system.
Solutions:
build-mode: manual and provide explicit build commandsgcc, make, cmake, or msbuild are available.NET SDK or MSBuild is installedgradle or maven is installedCause: The CodeQL tracer injects compiler flags that may conflict with project configuration.
Details: CodeQL injects /p:EmitCompilerGeneratedFiles=true which can cause issues with:
.sqlproj filesSolutions:
<EmitCompilerGeneratedFiles>false</EmitCompilerGeneratedFiles> to problematic project filesbuild-mode: none for C# if build accuracy is acceptableCause: Large codebase, complex queries, or insufficient resources.
Solutions:
build-mode: none where accuracy is acceptable (significantly faster)dependency-caching: truetimeout-minutes on the job to prevent hung workflows--threads=0 (CLI) to use all available CPU coresdefault suite instead of security-and-qualitypaths in config file to limit analyzed directoriesCause: Build command didn’t compile all source files, or build-mode: none missed generated code.
Solutions:
none to autobuild or manual build modeCause: Repository uses build-mode: none (Java only) but also contains Kotlin code.
Solutions:
autobuild)build-mode: autobuild for java-kotlinnone mode only works for JavaCause: GITHUB_TOKEN lacks required permissions.
Solutions:
permissions:
security-events: write
contents: read
actions: readpull_request_target instead of pull_requestCause: GitHub Code Security is not enabled.
Solution: Enable GitHub Code Security in repository Settings → Advanced Security.
Cause: Attempting to use code scanning on a private repo without the required license.
Solutions:
Cause: Both default setup and a pre-existing codeql.yml workflow are active.
Solutions:
Cause: Matrix configuration doesn’t include all languages.
Solutions:
matrix.include arrayjavascript-typescript not just javascript)build-modeSolutions:
on: triggers in the workflow fileCause: Invalid query or pack reference in the workflow.
Solutions:
owner/pack-name@version or owner/pack-name:path/to/query.qlcodeql resolve packs to verify available packsCause: Runner lacks sufficient resources for the analysis.
Solutions:
paths configurationbuild-mode: none to reduce resource usageCause: Some source files couldn’t be processed by the CodeQL extractor.
Solutions:
To get more detailed diagnostic information:
GitHub Actions:
CodeQL CLI:
codeql database create my-db \
--language=javascript-typescript \
--verbosity=progress++ \
--logdir=codeql-logsVerbosity levels: errors, warnings, progress, progress+, progress++, progress+++
Workflow logs include summary metrics:
For build-mode: none with private package registries:
Credentials loaded for the following registries: messageLimit: 10 MB maximum (gzip-compressed).
Solutions:
default instead of security-and-quality)--sarif-add-file-contents flagGitHub enforces limits on SARIF data objects:
| Object | Maximum |
|---|---|
| Runs per file | 20 |
| Results per run | 25,000 |
| Rules per run | 25,000 |
| Tool extensions per run | 100 |
| Thread flow locations per result | 10,000 |
| Location per result | 1,000 |
| Tags per rule | 20 |
Solutions:
--sarif-categorySolutions:
version is "2.1.0" and $schema points to the correct schemaruns, tool.driver, results) are presentCause: Cannot upload CodeQL-generated SARIF when default setup is active.
Solutions:
Solutions:
GITHUB_TOKEN environment variable with security-events: write scope--github-auth-stdin to pipe the token${{ secrets.GITHUB_TOKEN }}