fix: crash when a tool parameter is named properties (create_tool_from_function, @tool, ComponentTool)#12037
Merged
sjrl merged 2 commits intoJul 20, 2026
Conversation
…ords in _remove_title_from_schema Creating a Tool from a function or component with a parameter named 'properties' crashed with AttributeError: 'str' object has no attribute 'items'. The keys of a JSON schema 'properties' mapping are property names, so _remove_title_from_schema now always recurses only into the dict sub-schemas of that mapping instead of conditionally guarding just the name 'title'.
|
@sohumt123 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Hi @sohumt123, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
HaystackBot
marked this pull request as draft
July 17, 2026 08:00
sohumt123
marked this pull request as ready for review
July 17, 2026 16:26
sjrl
self-requested a review
July 20, 2026 06:31
sjrl
reviewed
Jul 20, 2026
Release notes render as reStructuredText, so inline code must use double backticks; convert the single-backtick spans accordingly.
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
remove_title_from_schema,'str' object has no attribute 'items', and tool-schemaAttributeErrorand found no report of this bug.Proposed Changes:
Creating a
Toolfrom any function whose signature has a parameter namedpropertiescrashes withAttributeError: 'str' object has no attribute 'items'. All ofcreate_tool_from_function, the@tooldecorator, andComponentTool(which imports the same helper) are affected, and a parameter namedpropertiesis quite realistic for LLM tools (e.g. "set/update entity properties" tools for graph or DB backends):Root cause:
_remove_title_from_schemaspecial-caseskey == "properties" and isinstance(value, dict) and "title" in valueso that a property namedtitleis not deleted. But the keys of apropertiesmapping are property names, not schema keywords, and the guard only fires when a property namedtitlehappens to exist. When a property is namedproperties, one level deeper the iteration hitskey == "properties"whose value is that property's Pydantic sub-schema — which always contains atitlekeyword — so the branch triggers and recurses into raw scalar values like"Properties"and"string", calling.items()on astr.Fix: the
propertiesbranch now applies unconditionally and only recurses intodictsub-schemas, so property names are never interpreted as schema keywords. The existing behavior of preserving a property namedtitle(while still stripping thetitlekeyword inside its sub-schema) is unchanged and remains covered bytest_remove_title_from_schema_do_not_remove_title_property.Also added a release note under
releasenotes/notes/.How did you test it?
test_remove_title_from_schema_property_named_properties(unit test for the helper) andtest_from_function_with_parameter_named_properties(end-to-endcreate_tool_from_functiontest). Both fail onmainwith theAttributeErrorabove and pass with the fix.pytest test/tools/ -m "not integration"→269 passed, 11 deselected.ruff check/ruff format --checkandmypy haystack/tools/from_function.pypass on the changed files.Notes for the reviewer
from_function.pybut only moves the_remove_title_from_schema(schema)call site; it does not touch the helper, so this fix is orthogonal (trivial rebase either way).Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.