Skip to content

Fix #4423: Auto-parse JSON string config in Mem0Storage#4424

Closed
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770651431-fix-mem0-json-string-config
Closed

Fix #4423: Auto-parse JSON string config in Mem0Storage#4424
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770651431-fix-mem0-json-string-config

Conversation

@devin-ai-integration
Copy link
Contributor

Fix #4423: Auto-parse JSON string config in Mem0Storage

Summary

Mem0Storage crashes with AttributeError: 'str' object has no attribute 'get' when config is provided as a JSON string instead of a dict. This is common when configs are loaded from environment variables, CLI arguments, or config files.

The fix adds a _parse_config static method that:

  • Passes dict configs through unchanged (existing behavior)
  • Auto-parses valid JSON strings into dicts
  • Raises clear TypeError messages for invalid JSON strings, JSON that doesn't decode to a dict, or unsupported types (e.g. int)

Review & Testing Checklist for Human

  • Verify the behavior change for empty string "" config is acceptable — previously config or {} would silently convert it to {}, now it raises TypeError since "" is not valid JSON. This is arguably stricter but more correct.
  • Confirm TypeError is the right exception type for all three error cases (invalid JSON, non-dict JSON, wrong type). Could argue ValueError for the JSON decode failure.
  • Quick smoke test: pass a JSON string config like '{"agent_id":"x","user_id":"y"}' to Mem0Storage(type="external", config=...) and verify it initializes correctly end-to-end.

Notes

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration
Copy link
Contributor Author

Closing due to inactivity for more than 7 days. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Mem0Storage crashes when config is provided as a JSON string

0 participants