[quality] a 0-byte OWNERS file fails every OWNERS-reading run with "invalid OWNERS file returned from GitHub API" (decode treats content "" as missing)
Maintainer thường phản hồi trong vòng 2 ngày
Một pull request liên quan đã được merge.
- #416 của @mrbobbytables — đã merge
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- github-actions, typescript
- Lĩnh vực
- devtools
Hướng nghiên cứu
Start at the two truthiness checks in src/utils/owners.ts (around lines 161-167, in loadOwnersTree/probeOwners) and src/utils/auth.ts (around lines 493-495, in retrieveOwnersFile), then read parseOwners at owners.ts:39 to see the empty-document arm. Done when a blob with content '' decodes to an empty string and is treated as an OWNERS file listing nobody, with new cases in tests/utils/ownersAuth.test.ts and tests/utils/auth.test.ts, and npm run build followed by npm run pack passes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Finding
A 0-byte OWNERS file makes every OWNERS-reading run fail with invalid OWNERS file returned from GitHub API, instead of being read as an OWNERS file that lists nobody.
Both decode sites test the blob's content for truthiness:
// src/utils/owners.ts:161-167 (loadOwnersTree / probeOwners, via git/blobs and contents)
if (!file.content || !file.encoding) {
throw new Error(`invalid OWNERS file returned from GitHub API for ${path}`)
}
// src/utils/auth.ts:493-495 (retrieveOwnersFile, root OWNERS via contents)
if (!data.content || !data.encoding) {
throw new Error(`invalid OWNERS file returned from GitHub API: ${data}`)
}
but GitHub returns an empty blob with content: "" (which is falsy) and encoding: "base64". Verified against the real API on this repository with the universal empty-blob SHA:
$ gh api repos/cncf/prow-github-actions/git/blobs/e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
{"sha":"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391","size":0,"content":"","encoding":"base64",…}
Driven through dist/index.js on main @ 20d49e7 with /approve by alice on a pull request whose base has a root OWNERS of 0 bytes (fake GitHub serving { encoding: 'base64', content: '' } for the blob, i.e. exactly the shape above):
::error::TypeError: error handling issue comment: Error: error loading OWNERS files at basesha: Error: invalid OWNERS file returned from GitHub API for OWNERS
exit 1, no comment, no label — whereas the same file holding a single newline ("\n") is parsed by parseOwners (contents.trim() === '' ? {} : yaml.load(contents), owners.ts:39) as an OWNERS file that names nobody, and the run refuses alice normally (alice is not an approver for any changed file). The trim() === '' arm exists precisely to accept an empty file, but the decoder in front of it never lets a genuinely empty one through.
Blast radius: loadOwnersTree is shared by /approve, /lgtm under OWNERS, the approve/ownersLabel/blunderbuss pull-request plugins and the pull-request OWNERS authorization, so one 0-byte OWNERS anywhere under a changed file's ancestor directories fails all of them; retrieveOwnersFile additionally gates issue-side commands on the root OWNERS. A 0-byte placeholder (touch OWNERS) is a common way to stage the file.
The unit suite pins the current check only for the missing-key shape: __tests__/utils/ownersAuth.test.ts:296 and __tests__/utils/auth.test.ts:362 both serve a blob without a content key. No unit or bundle test serves content: "".
Recommendation
One deliverable (the same one-token edit at both sites plus the tests that pin it):
-
src/utils/owners.ts:163:if (file.content === undefined || !file.encoding)(ortypeof file.content !== 'string') so""decodes to""and reachesparseOwners's empty-document arm -
src/utils/auth.ts:493: the same change for the root OWNERS read - add a
content: ''case to__tests__/utils/ownersAuth.test.tsand__tests__/utils/auth.test.tsasserting the file is treated as listing nobody (and thatretrieveOwnersFilereturns'', which its callers already treat as "no root OWNERS") -
npm run build && npm run packso the dist/ drift gate passes
This touches production source, so it is not a PR this lane opens; it is filed for a maintainer. The companion bundle PR (__tests__/bundle/ownersParseArms.test.ts) drives the whitespace-only, list, scalar and non-string-role shapes of parseOwners through dist/index.js and deliberately leaves the 0-byte shape out, naming this issue, so that the test does not pin the current failure as expected behaviour.
Priority
- Impact: medium (one 0-byte OWNERS file disables every OWNERS-backed command on the paths it covers; the error message blames the GitHub API, so it is hard to diagnose)
- Effort: low
🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: unknown
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88
- Ngôn ngữ chính
- TypeScript
- Star
- 132
- Fork
- 23
- Merge trung bình
- 1 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 183
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cncf/prow-github-actions
-
[quality] coverage-e2e names tide.ts:99 uncovered; the zero is the never-reached `options.initial ?? await getPull` fallback on line 98Có thể đã có người làm @hivecommons-hive đã nhận hôm nay. Đang mở🐝 covered by PR agent/quality hive/claimed-by-quality hive/hosted-available-lke648397-260827-5q9t hive/verified-open needs-kind quality stage/030-pr-in-progress testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
cncf/prow-github-actions#466 · 46 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
🐝 Hive Advisory ReportĐang mởkind/cleanup
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
cncf/prow-github-actions#170 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của cncf/prow-github-actions
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
umami-software/umami#4637 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Hotkeys fire when pressed with the Ctrl key, so browser shortcuts also trigger player actionsCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
muxinc/media-chrome#1332 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
polarsource/polar#15580 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
accepted bug via-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
pingdotgg/t3code#20931 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug/1-unconfirmed kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày