[quality] comment-only prow.yaml throws YAMLException instead of loading as an empty configuration (parseProwConfig trim guard misses zero-document input)
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #415 de @mrbobbytables — fusionado
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 65/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- github-actions, nodejs, typescript
- Área
- tooling
Línea de trabajo
Empieza en parseProwConfig en src/utils/config.ts (alrededor de las líneas 369-374), donde la guarda trim() solo detecta entradas en blanco antes de yaml.load. Reproduce el problema con el fragmento de js-yaml del issue y luego amplía la rama de documento vacío para cubrir entradas que solo contienen comentarios. Está listo cuando # prow configuration\n devuelve {} y los casos añadidos pasan en tests/utils/config.test.ts y tests/bundle/emptyConfigDocument.test.ts, con npm run build && npm run pack ejecutado para que dist/ quede actualizado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 132
- Forks
- 24
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 240
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de cncf/prow-github-actions
-
🐝 Hive Advisory ReportAbiertohive/advisory kind/cleanup
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
cncf/prow-github-actions#170 · 9 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de cncf/prow-github-actions
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
kunchenguid/gh-axi#247 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
lidge-jun/opencodex#8101 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
effort:S P3 refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
nightscout/nocturne#3243 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
JuliusBrussee/caveman#1449 ·
Los mantenedores suelen responder en 1 día