Skip to content

fix(docx): normalize style type list to numbering to avoid load failure - #4868

Closed
taran-dev4u wants to merge 1 commit into
docling-project:mainfrom
taran-dev4u:fix/docx-w-type-list-style-mapping
Closed

taran-dev4u wants to merge 1 commit into
docling-project:mainfrom
taran-dev4u:fix/docx-w-type-list-style-mapping

Conversation

@taran-dev4u

Copy link
Copy Markdown
Contributor

Resolves #4830

Some third-party generators declare styles with w:type="list" in word/styles.xml instead of w:type="numbering". Because python-docx maps its WD_STYLE_TYPE.LIST enum to XML value "numbering", encountering list raises ValueError: WD_STYLE_TYPE has no XML mapping for 'list' when resolving default styles or accessing unstyled paragraphs.

This normalizes w:type="list" to w:type="numbering" on loaded style elements in MsWordDocumentBackend before default style resolution, allowing python-docx to parse list styles as WD_STYLE_TYPE.LIST. Added unit test test_docx_styles_xml_with_type_list_converts in tests/test_backend_msword.py.

Checklist:

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

Review evidence:

  • Verified reproduction failure locally with ValueError: WD_STYLE_TYPE has no XML mapping for 'list'.
  • Verified fix with pytest tests/test_backend_msword.py -k test_docx_styles_xml_with_type_list_converts (1 passed).
  • Ran all 86 unit tests in tests/test_backend_msword.py (86 passed, 1 skipped).
  • Ran ruff check, ruff format --check, and tach check (all clean).

Signed-off-by: Taran Mamidala <mamidalataran6333@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @taran-dev4u, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 16, 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)(?:\(.+\))?(!)?:

@taran-dev4u
taran-dev4u marked this pull request as ready for review October 16, 2026 22:25
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working docx issue related to docx backend labels Oct 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 4719af75f0. The analysis read the diff only. It did not run code from this pull request.

Normalize the DOCX style type list to numbering in MsWordDocumentBackend to prevent errors during style resolution.

Topic labels added: bug, docx.

CI safety: no concern found. A maintainer must still approve CI.

Possible duplicates

PR State Signal Assessment
#4831 open also references issue #4830; changes the same code duplicate: Both pull requests fix issue #4830 by converting the DOCX style type list to numbering before resolving default styles.
1 related pull request(s) in the same code
PR State Signal Assessment
#4862 open changes the same code related: PR 4862 modifies style lookups in MsWordDocumentBackend to add caching instead of fixing invalid style types.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@taran-dev4u

Copy link
Copy Markdown
Contributor Author

Closing in favor of #4831, which already addresses #4830.

@taran-dev4u
taran-dev4u deleted the fix/docx-w-type-list-style-mapping branch October 17, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working docx issue related to docx backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOCX conversion fails when styles.xml declares a style with w:type="list"

1 participant