fix(asciidoc): stop a dedented list from crashing the backend#3826
fix(asciidoc): stop a dedented list from crashing the backend#3826chuenchen309 wants to merge 1 commit into
Conversation
An AsciiDoc list that starts indented and then dedents back to the base level raised `TypeError: '<' not supported between instances of 'int' and 'NoneType'`. The dedent loop keeps decrementing `level` and comparing `item["indent"] < indents[level]`, but `indents[0]` (the base level) is never assigned an int, so once the loop walks past level 0 the comparison hits `None`. Stop the loop at level 0, where there is no enclosing list to dedent out of. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
❌ DCO Check Failed Hi @chuenchen309, your pull request has failed the Developer Certificate of Origin (DCO) check. This repository supports remediation commits, so you can fix this without rewriting history — but you must follow the required message format. 🛠 Quick Fix: Add a remediation commitRun this command: git commit --allow-empty -s -m "DCO Remediation Commit for chuenchen309 <48723787+chuenchen309@users.noreply.github.com>
I, chuenchen309 <48723787+chuenchen309@users.noreply.github.com>, hereby add my Signed-off-by to this commit: 9b784cbb45e58342d6130c7e7a5639d546888081"
git push🔧 Advanced: Sign off each commit directlyFor the latest commit: git commit --amend --signoff
git push --force-with-leaseFor multiple commits: git rebase --signoff origin/main
git push --force-with-leaseMore info: DCO check report |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@chuenchen309 thanks for the proposed fix. I think this is needed. On the other hand, checking the PR against the spec, it seems that we should also fix the parsing according to the AsciiDoc spec. In the specific Per the spec this is a flat two-item list (both single Do you want to address this here directly? (otherwise we will have some follow up issue for it) |
An AsciiDoc list that starts indented and then dedents back to the base level crashes the backend:
The dedent loop in
_parse_list_itemhandling keeps decrementingleveland comparingitem["indent"] < indents[level], butindents[0](the base level) is never assigned an int — onlyindents[level + 1]is set when a list starts or nests deeper. So once the loop walks past level 0 the comparison hitsNoneand raises.The fix stops the loop at level 0, where there is no enclosing list to dedent out of. Nested and flat lists are unaffected; only the previously-crashing dedent-to-base case changes (it now keeps both items).
Checklist:
test_list_dedent_to_base_does_not_crashconverts" * a\n* b\n"and asserts both items survive; it fails before this change (TypeError) and passes after. The existingtests/test_backend_asciidoc.pystays green (7 passed);ruff check/ruff formatpass.Disclosure: this contribution is fully AI-authored and autonomous (Claude Code, acting on this account). An AI found the bug, wrote and ran the repro and the test, and wrote this description; the human account holder reviews every change and is accountable for it. The verification above is real and re-runnable from the diff. If this isn't the kind of contribution you want, say so and I'll close it.