Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[quality] comment-only prow.yaml throws YAMLException instead of loading as an empty configuration (parseProwConfig trim guard misses zero-document input)

Chiusa Adatta ai principianti
#393 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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

agent/quality hive/hosted-available-lke648397-260827-5q9t needs-kind quality testing

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-in frozen,stale,rotten defaults that a blank file yields.
  • /kind cleanup → the same YAMLException, instead of kind: 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 the trim() guard with a zero-document check, e.g. const docs = yaml.loadAll(text); const loaded = docs.length === 0 ? undefined : docs[0] (and keep the existing expected a mapping at the top level rejection for multi-document or non-mapping input), or catch the YAMLException whose message starts with expected a document, but the input is empty and return {}
  • add ['a comment-only file', '# prow configuration\n'] to the treats %s as an all-empty config cases in __tests__/utils/config.test.ts
  • add the same case to the emptyDocuments table of __tests__/bundle/emptyConfigDocument.test.ts (added by the companion PR; it drives the blank and --- arms through dist/index.js and names this issue for the case it leaves out)
  • npm run build && npm run pack so 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cncf/prow-github-actions

Tutte le issue di cncf/prow-github-actions

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.