Skip to content

Edit a card that ends at its closing fence - #101

Merged
sw005320 merged 1 commit into
espnet:masterfrom
sw005320:zoo/front-matter-no-newline
Sep 19, 2026
Merged

sw005320 merged 1 commit into
espnet:masterfrom
sw005320:zoo/front-matter-no-newline

Conversation

@sw005320

Copy link
Copy Markdown
Collaborator

One of the 389 cards in #100's run failed:

espnet/DCASE23.AudioCaptioning.PreTrained: FAILED AssertionError: front matter changed

The card is front matter and nothing else — 182 bytes ending at --- with no
newline after it. So split_front_matter returned a front matter that does not
end in a newline, and insert_snippet wrote the snippet straight onto it:

license: cc-by-4.0
---## Usage

which stops being a closing fence. The whole metadata block would have become
body text. The guard caught it, which is the guard doing its job; it then
reported "front matter changed", which is not what a reader would go looking
for.

Two bugs in one, so two halves:

  • insert_snippet gives the fence the newline it needs, so the snippet starts
    on its own line and the card reads like every other one.
  • the guard compares the metadata rather than its trailing whitespace — that
    newline is punctuation between the front matter and the body, not a change to
    what the front matter says.

Verified against the real card fetched from the Hub: the guard passes and the
output is ---\n\n## Usage. Two tests, one for each half, plus the idempotence
check that a second run skips the card it has already edited.

The other 388 were unaffected: every other card ends its front matter with a
newline.

🤖 Generated with Claude Code

One of the 389 failed: espnet/DCASE23.AudioCaptioning.PreTrained is front
matter and nothing else, ending at --- with no newline after it.

insert_snippet wrote the snippet straight onto that fence, so the
metadata's own closing --- would have become the start of a line of body
text and the whole front matter with it. The guard that compares the
front matter before and after caught it - correctly, and then reported it
as "front matter changed", which is not what a reader would go looking
for.

Two halves, because there were two bugs in one. The fence now grows the
newline it needs, so the snippet starts on its own line and the card
reads like every other one. And the guard compares the metadata rather
than its trailing whitespace: that newline is punctuation between the
front matter and the body, not a change to what the front matter says.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mergify

mergify Bot commented Sep 19, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: espnet/espnet_model_zoo/.coderabbit.yaml

Review profile: QUIET

Plan: Advanced

Run ID: 97210ef1-0be0-410e-b925-f884a144d002

📥 Commits

Reviewing files that changed from the base of the PR and between 9a048be and f4375d1.

📒 Files selected for processing (2)
  • espnet_model_zoo/hub_usage_snippets.py
  • test/test_hub_usage_snippets.py

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

insert_snippet now adds a newline after a closing front-matter fence when the fence is at the end of the file. apply compares front matter after removing trailing whitespace. Tests cover insertion, front-matter separation, and preventing duplicate snippets.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: editing cards that end at the closing front matter fence.
Description check ✅ Passed The description directly explains the front matter newline bug, the guard update, the tests, and the expected behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.17%. Comparing base (9a048be) to head (f4375d1).

Files with missing lines Patch % Lines
espnet_model_zoo/hub_usage_snippets.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #101   +/-   ##
=======================================
  Coverage   65.17%   65.17%           
=======================================
  Files           5        5           
  Lines        1160     1163    +3     
=======================================
+ Hits          756      758    +2     
- Misses        404      405    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sw005320
sw005320 merged commit f76ed8a into espnet:master Sep 19, 2026
6 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.

2 participants