docling icon indicating copy to clipboard operation
docling copied to clipboard

StringConstraints() takes no arguments

Open yiminl18 opened this issue 1 year ago • 3 comments

Bug

I created a virtual environment and pip install docling. When I run the given example code, it failed and returned the above error.

from docling.document_converter import DocumentConverter

source = "https://arxiv.org/pdf/2408.09869" # file path or URL converter = DocumentConverter() doc = converter.convert(source).document

print(doc.export_to_markdown()) # output: "### Docling Technical Report[...]"

yiminl18 avatar Aug 26 '25 18:08 yiminl18

Hi @yiminl18! I'm Dosu and I’m helping the docling team.

The error happens because the installed version of Pydantic is too old—docling expects Pydantic v2 or higher, where StringConstraints is available and accepts arguments. In older versions, StringConstraints either doesn't exist or can't be called with arguments, which triggers this error when docling tries to validate fields like version in its data models (example).

To fix this, upgrade Pydantic in your environment:

pip install --upgrade pydantic

Then re-run your code. This should resolve the error and allow the example to work as intended.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about docling Share Dosu with your team

dosubot[bot] avatar Aug 26 '25 18:08 dosubot[bot]

Hi @yiminl18, dosubot suggested an answer above but there's been no confirmation either way. Did that resolve it for you, or should this stay open? If we don't hear back within a week, we'll close it. Feel free to reopen if you see a need.

cau-git avatar Sep 01 '26 14:09 cau-git

Closing this issue because we did not hear back after our check-in on September 1. If it is still relevant for you, please reopen it or open a new issue with a current Docling version and a reproducer. Thanks!

cau-git avatar Oct 14 '26 13:10 cau-git