fix: handle JSON string config in Mem0Storage#4537
Open
hztBUAA wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix: handle JSON string config in Mem0Storage#4537hztBUAA wants to merge 1 commit intocrewAIInc:mainfrom
hztBUAA wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
When Mem0Storage receives config as a JSON string (common when loading from environment variables or config files), it now automatically parses it via json.loads() instead of crashing with AttributeError on .get(). Add _parse_config() static method that handles: - None -> empty dict - dict -> pass through unchanged - JSON string -> parse with json.loads() - invalid types -> raise clear TypeError - invalid JSON -> raise clear ValueError Fixes crewAIInc#4423
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Author
|
Thanks for the review and feedback. I am following up on this PR now and will either push the requested changes or reply point-by-point shortly. |
Author
|
Quick follow-up: I am reviewing the feedback and will update this PR shortly. |
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.
Summary
Mem0Storagecrashing withAttributeErrorwhenconfigis passed as a JSON string instead of a dict_parse_config()static method that auto-parses JSON strings, passes dicts through, and raises clear errors for invalid inputsmem0_storage.pyand itsStorageinterface (removed in New Unified Memory System #4420) so the mem0 optional integration remains availableFixes #4423
Changes
lib/crewai/src/crewai/memory/storage/mem0_storage.py: Add_parse_config()method; use it in__init__instead of bareconfig or {}lib/crewai/src/crewai/memory/storage/interface.py: Restore theStorageabstract base class required byMem0Storagelib/crewai/tests/storage/test_mem0_storage_config.py: 11 unit tests covering JSON string parsing, dict passthrough, None default, and error casesTest plan
ValueErrorwith helpful messageTypeErrorTypeError🤖 Generated with Claude Code