Skip to content

Fix remaining missing season key; catch duplicate keys in CI - #137

Merged
s0len merged 2 commits into
mainfrom
fix/title-cards-duplicate-season-keys
Aug 24, 2026
Merged

s0len merged 2 commits into
mainfrom
fix/title-cards-duplicate-season-keys

Conversation

@s0len

@s0len s0len commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Follow-up to #136. That PR fixed Colin from Accounts and noted "there might be others" — there was one more, and now CI will catch the next one.

The remaining break

That Time I Got Reincarnated as a Slime (TVDB 352408) was missing its 5: season key, so the fifth episodes: block landed inside season 4's mapping as a duplicate key:

      4:
        episodes:
          1: ...
          # ... 24 episodes
        episodes:      # <- orphaned; should be season 5 (13 episodes)
          1: ...

Kometa loads YAML through ruamel, which rejects duplicate keys, so the entire 45k-line file aborted for every user with the reported error:

found duplicate key "episodes" with value "{}" (original value: "{}")

Verified there are no other instances: every .yaml/.yml in the repo now loads cleanly under ruamel with duplicate-key checking on.

Why CI didn't catch it

validate_yaml.py uses pyyaml's safe_load, which silently accepts duplicate keys and keeps the last value. So both this and #136 passed CI while being fatal to every downstream config.

Added a check_duplicate_keys pass that walks the composed node tree rather than the loaded document, reporting every duplicate with line numbers instead of aborting on the first:

DUPKEY  metadata/series/title_cards.yaml:6433: duplicate key 'episodes' (first seen on line 6384)

Duplicate keys are treated as errors (non-zero exit), alongside syntax errors and broken references. No new dependency — it uses the pyyaml the workflow already installs.

Also routed the existing repo-relative path formatting through a _rel helper; relative_to raised ValueError when files were passed as relative CLI arguments (python3 scripts/validate_yaml.py metadata/series/title_cards.yaml).

Verification

  • python3 scripts/validate_yaml.py → 0 syntax error(s), 0 duplicate key(s), 0 broken reference(s)
  • The new check reproduces the bug on the pre-fix file and exits 1
  • Parsed result: 352408 → seasons 1–5 with 14/24/24/24/13 episodes; no title cards lost

🤖 Generated with Claude Code

s0len and others added 2 commits August 24, 2026 19:02
That Time I Got Reincarnated as a Slime (TVDB 352408) was missing the
`5:` season key, so its fifth `episodes:` block landed in season 4's
mapping as a duplicate key. Kometa loads YAML through ruamel, which
rejects duplicates, so the whole file aborted with:

    found duplicate key "episodes" with value "{}"

Same class of bug as #136 (Colin from Accounts), which the reporter
suspected was not the only instance -- it was not.

`validate_yaml.py` missed both because pyyaml's `safe_load` silently
keeps the last duplicate value. Added a `check_duplicate_keys` pass
that walks the composed node tree (reporting every duplicate, not just
the first) so CI fails on this instead of shipping it to users. No new
dependency -- it uses the pyyaml the workflow already installs.

Also routed the existing repo-relative path formatting through a `_rel`
helper; `relative_to` raised when files were passed as relative CLI
arguments.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@s0len
s0len merged commit 73fdb3e into main Aug 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant