[quality] comment-only prow.yaml throws YAMLException instead of loading as an empty configuration (parseProwConfig trim guard misses zero-document input)
I maintainer di solito rispondono entro 2 giorni
Una pull request collegata è già stata integrata.
- #415 di @mrbobbytables — integrata
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- github-actions, nodejs, typescript
- Ambito
- tooling
Direzione di ricerca
Inizia da parseProwConfig in src/utils/config.ts (intorno alle righe 369-374), dove la guardia trim() intercetta solo l'input vuoto prima di yaml.load. Riproduci il problema con lo snippet js-yaml della issue, poi estendi il ramo del documento vuoto in modo che copra input che contengono solo commenti. Il lavoro è completato quando # prow configuration\n restituisce {} e i casi aggiunti passano in tests/utils/config.test.ts e tests/bundle/emptyConfigDocument.test.ts, con npm run build && npm run pack eseguito così che dist/ sia allineata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 132
- Fork
- 24
- Merge medio
- 1g 18h
- PR unite (30g)
- 191
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cncf/prow-github-actions
-
[quality] prefixed.ts: /stage and /status exclusive replacement, two-value /remove-lifecycle, mixed-case allowlist values and the first protected offender survive mutationForse già presa @hivecommons-hive l’ha presa 1 giorno fa. Apertaagent/quality needs-kind stage/040-covered-by-pr testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
cncf/prow-github-actions#538 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[quality] approveReview.ts: a PAT that is not the author never has its review submission asserted, and withdrawalReason's five-file bound, lgtm skip, user casing and withdrawer order are unpinnedForse già presa @hivecommons-hive l’ha presa 1 giorno fa. Apertaagent/quality needs-kind stage/040-covered-by-pr testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
cncf/prow-github-actions#526 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[quality] trigger.ts: /test matches workflow names and paths case-insensitively, /ok-to-test honours an existing label in any case, and the non-PR arm of /test and /ok-to-test leaves the run green — none of it is assertedForse già presa @hivecommons-hive l’ha presa 2 giorni fa. Apertaagent/quality needs-kind stage/040-covered-by-pr testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
cncf/prow-github-actions#523 · 6 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
[quality] approve.ts: ten mutation survivors — any-Bot /approve, user-token bot review, require_self_approval break, approver sort, label casing, isBot notifier matchForse già presa @hivecommons-hive l’ha presa 2 giorni fa. Apertaagent/quality needs-kind stage/040-covered-by-pr testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
cncf/prow-github-actions#521 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
[quality] mutation survivors in src/plugins/requireMatchingLabel.ts: the withGracePeriod default, the graceMs > 0 guard, isBot's || and the no-rule debug text are not pinned by any testForse già presa @hivecommons-hive l’ha presa 2 giorni fa. Apertaagent/quality needs-kind stage/040-covered-by-pr testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cncf/prow-github-actions#519 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di cncf/prow-github-actions
Issue simili
-
frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
ranxianglei/billion-context#4172 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
awslabs/threat-composer#362 ·
I maintainer di solito rispondono entro 1 giorno
-
Area/Cloud Needs Triage Type/Bug
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
wso2/product-integrator#2847 ·
I maintainer di solito rispondono entro 1 giorno