Skip to content

fix(asciidoc): stop a dedented list from crashing the backend#3826

Open
chuenchen309 wants to merge 1 commit into
docling-project:mainfrom
chuenchen309:fix/asciidoc-dedent-list-crash
Open

fix(asciidoc): stop a dedented list from crashing the backend#3826
chuenchen309 wants to merge 1 commit into
docling-project:mainfrom
chuenchen309:fix/asciidoc-dedent-list-crash

Conversation

@chuenchen309

@chuenchen309 chuenchen309 commented Jul 18, 2026

Copy link
Copy Markdown

An AsciiDoc list that starts indented and then dedents back to the base level crashes the backend:

AsciiDocBackend(...).convert()   # source: "  * a\n* b\n"
# TypeError: '<' not supported between instances of 'int' and 'NoneType'

The dedent loop in _parse_list_item handling keeps decrementing level and comparing item["indent"] < indents[level], but indents[0] (the base level) is never assigned an int — only indents[level + 1] is set when a list starts or nests deeper. So once the loop walks past level 0 the comparison hits None and 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:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

test_list_dedent_to_base_does_not_crash converts " * a\n* b\n" and asserts both items survive; it fails before this change (TypeError) and passes after. The existing tests/test_backend_asciidoc.py stays green (7 passed); ruff check / ruff format pass.


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.

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>
@github-actions

Copy link
Copy Markdown
Contributor

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 commit

Run 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 directly

For the latest commit:

git commit --amend --signoff
git push --force-with-lease

For multiple commits:

git rebase --signoff origin/main
git push --force-with-lease

More info: DCO check report

@mergify

mergify Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dolfim-ibm

Copy link
Copy Markdown
Member

@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

* a
    * b

Per the spec this is a flat two-item list (both single *), but an indentation-driven parser is liable to treat * b as nested under * a, which would be wrong. So the fix is a correct and safe crash patch, but it doesn't address the underlying spec mismatch — it just stops the one dedent-to-base case from throwing.

Do you want to address this here directly? (otherwise we will have some follow up issue for it)

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