False positive — CodeQL failing due to lack of Python files when they only exist on the `main` branch
- Dominant language
- CodeQL
- Stars
- 10.1k
- Forks
- 2.1k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 141
Description
**Description of the false positive**
Hi, I encountered a weird issue with CodeQL. My pull request is based on a slightly older version of the codebase, which did not have any Python files. However, there is now a single Python file in `main`. CodeQL runs, but fails due to lack of Python files, which blocks a perfectly valid PR.
Unfortunately, the code is private, so I am not able to share the repository, but the `main` branch contains a Python script in `scripts/`, while the PR version of the codebase doesn't.
The exact error is
```
/opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/codeql database finalize --finalize-dataset --threads=2 --ram=6920 /home/runner/work/_temp/codeql_databases/python
CodeQL detected code written in C/C++, Swift, GitHub Actions and Java/Kotlin, but not any written in Python. Confirm that there is some source code for Python in the project. For more information, review our troubleshooting guide at https://gh.io/troubleshooting-code-scanning/no-source-code-seen-during-build .
Error: Encountered a fatal error while running "/opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/codeql database finalize --finalize-dataset --threads=2 --ram=6920 /home/runner/work/_temp/codeql_databases/python". Exit code was 32 and last log line was: CodeQL detected code written in C/C++, Swift, GitHub Actions and Java/Kotlin, but not any written in Python. Confirm that there is some source code for Python in the project. For more information, review our troubleshooting guide at https://gh.io/troubleshooting-code-scanning/no-source-code-seen-during-build . See the logs for more details.
```
I don't believe that CodeQL should be configured to run on file types that do not exist on a given branch. This can be fixed in a pretty simple way — rebasing the branch on top of HEAD, but still, I don't believe this should be a cause for failure in the first place.
Contributor guide
Research direction
Reproduce the failure with a pull request whose older base lacks Python while main contains a script in scripts/. Start with the CodeQL database finalization error and the linked no-source-code troubleshooting guide; done means a valid pull request does not fail solely because Python exists only on main.
Written by the indexing model from the issue text.
Assessment
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100