[quality] comment-only prow.yaml throws YAMLException instead of loading as an empty configuration (parseProwConfig trim guard misses zero-document input)
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #415 @mrbobbytables による — マージ済み
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 65/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- github-actions, nodejs, typescript
- 領域
- tooling
調査の方向性
src/utils/config.ts の parseProwConfig(369〜374行目付近)から始めます。ここでは yaml.load の前にある trim() のガードが空の入力だけを処理しています。issue の js-yaml スニペットで再現し、そのうえで空ドキュメントの分岐を、コメントだけの入力も扱えるように広げてください。# prow configuration\n が {} を返し、追加したケースが tests/utils/config.test.ts と tests/bundle/emptyConfigDocument.test.ts で通れば完了です。その後 npm run build && npm run pack を実行して dist/ を一致させてください。
索引モデルが issue の本文から書いたものです。
説明
Finding
A comment-only prow.yaml breaks every configuration-reading command. parseProwConfig (src/utils/config.ts:369-374) treats an empty document as an all-empty configuration:
const loaded: unknown = text.trim() === '' ? undefined : yaml.load(text)
if (loaded === undefined || loaded === null) {
return {}
}
but the guard only catches a blank/whitespace file. js-yaml 5 (^5.4.2, bumped in #126) throws YAMLException: expected a document, but the input is empty from load() whenever the input contains zero documents, and a file holding only comments is such an input:
$ node -e "const y=require('js-yaml');for (const t of ['','# c\n','---\n',' \n']){try{console.log(JSON.stringify(t),'->',y.load(t))}catch(e){console.log(JSON.stringify(t),'THROWS',e.message)}}"
"" THROWS expected a document, but the input is empty
"# c\n" THROWS expected a document, but the input is empty
"---\n" -> null
" \n" THROWS expected a document, but the input is empty
So '' and ' \n' are rescued by the trim() guard, '---\n' loads as null, and '# c\n' falls through to yaml.load and throws. Driven through dist/index.js on main @ aa6a0f8 with .github/prow.yaml = # prow configuration\n# nothing enabled yet\n:
/lifecycle stale→ exit 1,::error::TypeError: error handling issue comment: Error: could not get labels from yaml: YAMLException: expected a document, but the input is empty— instead of the built-infrozen,stale,rottendefaults that a blank file yields./kind cleanup→ the sameYAMLException, instead ofkind: yaml malformed, expected 'kind' top level key.
The same path runs for the org tier (<owner>/.project / <owner>/.github:prow.yaml), so a placeholder, comment-only org file breaks every repository in the organization.
History: #126's commit message accepted the new throw on empty documents ("the failure mode is unchanged"); #144 then deliberately made empty documents an all-empty configuration (return {}) and unit-tested '', '---\n' and ' \n' (__tests__/utils/config.test.ts:420-426) but not a comment-only document, which is the one shape users actually commit as a placeholder.
Recommendation
One deliverable: make the empty-document arm cover zero-document input regardless of comments. Either
- in
parseProwConfig, replace thetrim()guard with a zero-document check, e.g.const docs = yaml.loadAll(text); const loaded = docs.length === 0 ? undefined : docs[0](and keep the existingexpected a mapping at the top levelrejection for multi-document or non-mapping input), or catch theYAMLExceptionwhose message starts withexpected a document, but the input is emptyand return{} - add
['a comment-only file', '# prow configuration\n']to thetreats %s as an all-empty configcases in__tests__/utils/config.test.ts - add the same case to the
emptyDocumentstable of__tests__/bundle/emptyConfigDocument.test.ts(added by the companion PR; it drives the blank and---arms throughdist/index.jsand names this issue for the case it leaves out) -
npm run build && npm run packso the dist/ drift gate passes
This touches production source (src/utils/config.ts), so it is not a PR this lane opens; it is filed for a maintainer.
Priority
- Impact: medium (a comment-only placeholder config silently disables every label command for a repository or, at the org tier, every repository)
- Effort: low
🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: aa6a0f8
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88
- 主要言語
- TypeScript
- スター
- 132
- フォーク
- 24
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 232
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cncf/prow-github-actions のほかの issue
-
agent/quality kind/cleanup stage/045-needs-decision testing
難易度 3/5 1〜2日 初心者へのやさしさ 15/100
cncf/prow-github-actions#672 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[quality] chart: CronJob name exceeds the 52-character API limit for release names of 32+ characters; no test pins resource-name length対応中かも @mrbobbytables が 1 日前に担当しました。 オープンagent/quality kind/cleanup stage/040-covered-by-pr testing
難易度 3/5 半日 初心者へのやさしさ 50/100
cncf/prow-github-actions#667 ·
メンテナーはふだん 1 日以内に返信
-
hive/advisory kind/cleanup
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
cncf/prow-github-actions#170 · コメント 9 件 ·
メンテナーはふだん 1 日以内に返信
cncf/prow-github-actions の issue をすべて見る
似ている issue
-
area: frontend priority: normal
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
formbricks/formbricks#9918 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
thecodacus/pithagoras#364 ·
メンテナーはふだん 1 日以内に返信
-
TestAutonomousStop_ReportsObservedState fails under host load: 1s wall-clock ceiling vs 250ms cycleオープンtype:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
nightgauge/nightgauge#2909 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信