fix: validate non-string keys in nested dicts during component serialization - #11954
Merged
anakin87 merged 1 commit intoJul 10, 2026
Merged
Conversation
…ization
The component_to_dict output validator only checked the top-level dict for
non-string keys: the nested check_dict recursion inspected the outer 'data'
instead of the dict passed to it ('d'), so a non-string key inside a nested
init_parameters value silently passed validation and could later fail at
marshal time. Check the recursed dict's own keys.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@Vedant-Agarwal is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
anakin87
approved these changes
Jul 10, 2026
anakin87
left a comment
Member
There was a problem hiding this comment.
Good catch.
I explored this repo and core integrations and could not find any cases where applying this fix would be problematic.
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
default_from_dictfix, though it happens to live in the same module).Proposed Changes:
_validate_component_to_dict_outputwalks a component's serialized data and rejects non-string keys (which don't round-trip through JSON). Its innercheck_dict(d)is recursive, but the non-string-key check iterated the outer closure variabledata(the top-level dict) instead of its own parameterd:So only the top-level keys were ever checked. A non-string key inside a nested
init_parametersvalue (e.g.{"mapping": {1: "a"}}) passed validation and could later fail opaquely at YAML/JSON marshal time — exactly what this validator exists to catch early. Fix: check the recursed dict's own keys (for k in d).How did you test it?
test_component_to_dict_nested_non_string_key, which serializes a component whoseinit_parameterscontains a nested{1: "a"}and assertscomponent_to_dictraisesSerializationError. It fails onmain(DID NOT RAISE) and passes with the fix.python -m pytest test/core/test_serialization.py→ all green (27 tests).ruff check/ruff format --checkclean on both files.Notes for the reviewer
One-word fix (
data→d) restoring the intended recursive validation; the value-type check on the same recursion already usedvcorrectly, so only the key check was affected.This PR was written with the help of an AI assistant. I have reviewed the changes and run the relevant tests locally.
Checklist
fix:).