github / github/codeql

False positive — CodeQL failing due to lack of Python files when they only exist on the `main` branch

未關閉
#21,106 4 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
acknowledged bug false-positive
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

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

貢獻指南

開啟貢獻指南

研究方向

使用一個較舊的 base 不包含 Python、而 main 在 scripts/ 中包含指令碼的 pull request 重現此失敗。先從 CodeQL 資料庫最終化錯誤和連結的 no-source-code 疑難排解指南開始;完成的標準是,有效的 pull request 不會僅僅因為 Python 只存在於 main 而失敗。

由索引模型根據 Issue 內容生成。

評估

領域
security
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。