Skip to content

Conversation

@ceberam
Copy link
Collaborator

@ceberam ceberam commented Nov 13, 2025

The transform_to_content_layer model validator of DoclingDocument is of type before, since it may need to transform the raw input before the DoclingDocument is instantiated.
However, it assumes that the raw input data is a dict and this may create issues like described in docling-project/docling#2616.
Since before validators have to deal with the raw input, which in theory could be any arbitrary object, a type check has been added.

Resolves docling-project/docling#2616

@ceberam ceberam self-assigned this Nov 13, 2025
@ceberam ceberam added the bug Something isn't working label Nov 13, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

DCO Check Passed

Thanks @ceberam, all your commits are properly signed off. 🎉

@dosubot
Copy link

dosubot bot commented Nov 13, 2025

Related Documentation

Checked 3 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@mergify
Copy link

mergify bot commented Nov 13, 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)(?:\(.+\))?(!)?:

🟢 Require two reviewer for test updates

Wonderful, this rule succeeded.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

cau-git
cau-git previously approved these changes Nov 13, 2025

# test that transform_to_content_layer model validator can handle any data type
class ContentOutput(BaseModel):
content: str | DoclingDocument
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Union needed here for 3.9

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have also added a minor update in README

Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
@ceberam ceberam force-pushed the fix/model-validator-2616 branch from 99dec97 to ab24dd7 Compare November 13, 2025 14:04
@ceberam ceberam merged commit 56b3c42 into main Nov 13, 2025
13 checks passed
@ceberam ceberam deleted the fix/model-validator-2616 branch November 13, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transform_to_content_layer should not be using @model_validator(mode="before")

4 participants