Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix a bug while processing markdown file: 'str' object has no attribute 'get_ref' #133

Closed
wants to merge 2 commits into from

Conversation

eai1111
Copy link

@eai1111 eai1111 commented Jan 23, 2025

I've reached an unexpected crash while processing markdown (.md) files.

Stacktrace:

  File "/root/envs/eth/lib/python3.10/site-packages/docling/backend/md_backend.py", line 306, in iterate_elements
    self.iterate_elements(child, depth + 1, doc, parent_element)
  File "/root/envs/eth/lib/python3.10/site-packages/docling/backend/md_backend.py", line 306, in iterate_elements
    self.iterate_elements(child, depth + 1, doc, parent_element)
  File "/root/envs/eth/lib/python3.10/site-packages/docling/backend/md_backend.py", line 224, in iterate_elements
    doc.add_picture(parent=parent_element, caption=element.title)
  File "/root/envs/eth/lib/python3.10/site-packages/docling_core/types/doc/document.py", line 1602, in add_picture
    fig_item.captions.append(caption.get_ref())
AttributeError: 'str' object has no attribute 'get_ref'

Example data:

[![text](https://example.com "text")](https://example.com "text")

The caption is neither a text nor a ref item, it's a str. So get_ref should not be executed there.

Copy link

mergify bot commented Jan 23, 2025

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

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)(?:\(.+\))?(!)?:

@eai1111 eai1111 changed the title Fix a bug while processing markdown file: 'str' object has no attribute 'get_ref' fix: Fix a bug while processing markdown file: 'str' object has no attribute 'get_ref' Jan 23, 2025
@dolfim-ibm
Copy link
Contributor

The issue you report is actually a bug in the markdown backend. We have already a fix in place in a development PR which is going be released soon (like tomorrow).
https://github.com/DS4SD/docling/pull/752/files#diff-73af24b47bbe13d937125cc60da41fb12b2f8ec43f33c95f83385b9a67c5fca5L224

@eai1111
Copy link
Author

eai1111 commented Jan 24, 2025

awesome!

@dolfim-ibm
Copy link
Contributor

I'm closing this PR, since the issue is addressed in the new Docling release.

@dolfim-ibm dolfim-ibm closed this Jan 27, 2025
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