Skip to content

Conversation

@ialisaleh
Copy link
Collaborator

@ialisaleh ialisaleh commented Dec 19, 2025

Closes #2507


Note

Stringifies non-string dict keys and normalizes containers before JSON serialization, updating _json_dumps/safe_json_dumps and adding focused tests.

  • Serialization:
    • Add _stringify_dict_keys to recursively convert dict keys to strings and normalize containers (sets→lists, tuples/lists preserved).
    • Wrap original safe_json_dumps with a new safe_json_dumps that normalizes objects first.
    • Update _json_dumps to normalize input, use custom encoder, and catch RecursionError fallback to safe_json_dumps.
    • Adjust imports to alias original safe_json_dumps as _original_safe_json_dumps.
  • Tests:
    • Add test_stringify_dict_keys.py with cases covering Enums, sets/frozensets, tuples, nested structures, and primitives.

Written by Cursor Bugbot for commit e06ff15. This will update automatically on new commits. Configure here.

@ialisaleh ialisaleh self-assigned this Dec 19, 2025
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 19, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Dec 19, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[bug] [langchain] JSON serialization fails with non-string dictionary keys (e.g., Azure PISubType enum)

1 participant