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

Đang mở
#340 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 6 ngày

@TanmayShah29 đang làm issue này rồi.

Từ ngày 18/11/2026.

  • #342 của @TanmayShah29 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
github-actions, python
Lĩnh vực
testing, tooling

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
53.9k
Fork
4.3k
Merge trung bình
6 ngày 11 giờ
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của blader/humanizer

Tất cả issue của blader/humanizer

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.