validate-package.py: duplicated pattern section in SKILL.md passes validation (dict key collapse defeats the numbering check)

Abierto
#340 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 6 días

@TanmayShah29 ya está trabajando en esto.

Desde el 18/11/2026.

  • #342 de @TanmayShah29 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
github-actions, python
Área
testing, tooling

Línea de trabajo

Read scripts/validate-package.py and inspect how it parses pattern headings from SKILL.md and README.md. Reproduce the duplicate heading case, then check that validation rejects duplicate numbers in both files before checking the numbering range. The issue names .github/workflows/validate.yml as the CI entry point; done means the validator reports the duplicate clearly and the existing CI check runs it.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

scripts/validate-package.py collects the pattern headings from SKILL.md (and README.md) into a dict keyed by pattern number:

skill_patterns = dict((int(number), name) for number, name in re.findall(r"(?m)^### ([0-9]+)\. (.+)$", SKILL))
pattern_numbers = list(skill_patterns)
if pattern_count == 0 or pattern_numbers != list(range(1, pattern_count + 1)):
    raise SystemExit(...)

Because the headings go into a dict keyed by number, a duplicated ### N. heading overwrites the first occurrence instead of registering as an extra pattern. The numbering check only ever sees the unique keys, so it cannot detect a duplicated (shadowed) pattern section.

Reproduction

On a clean checkout of v4.0.0 (commit b48c832):

  1. Duplicate one pattern section in SKILL.md verbatim — e.g. copy the whole ### 7. Repeated sentence openings section so SKILL.md contains 27 pattern headings with two §7 sections.
  2. Run the validator:
$ grep -c '### 7\.' SKILL.md
2
$ python3 scripts/validate-package.py
Humanizer package v4.0.0 is valid

Exit code 0 — the package validates despite the duplicated pattern.

Expected

The validator should fail when a pattern number appears more than once in SKILL.md (and likewise for README.md, which is parsed the same way).

Actual

Validation passes. A merge that duplicates or shadows a pattern section would ship green through CI (.github/workflows/validate.yml runs exactly this script).

Related symptom of the same root cause: if the duplicated heading's name differs from the original, the validator does fail, but with a misleading message blaming the README ("Match the README pattern names to SKILL.md: 7: … should be …") rather than reporting the duplicate heading in SKILL.md.

Suggested direction

Collect the matches as a list and check for duplicate numbers explicitly (or compare the number of regex matches against the dict size) before the range check, for both SKILL.md and README.md.

Environment

  • Repo at commit b48c832 (v4.0.0)
  • Validator run locally with Python 3
Lenguaje dominante
Python
Estrellas
53.9k
Forks
4.3k
Merge medio
6 d 11 h
PR fusionados (30 d)
9

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de blader/humanizer

Todos los issues de blader/humanizer

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.