mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
fix: prevent crash when parsing invalid JSON in memory messages (#3280)
## Overview
Improved error handling in the memory component's JSON parsing to
prevent crashes when parsing invalid JSON content.
## Problem
The application would crash when the memory component encountered
strings starting with '[' or '{' that were not valid JSON. The
parseMessages method was attempting to parse these strings as JSON
without proper error handling, resulting in uncaught exceptions.
## Changes
Implemented a try-catch block in the parseMessages method when
attempting to parse JSON, ensuring the application properly handles
exceptions. This allows the application to continue using the original
string content instead of crashing when invalid JSON is encountered.
## Testing
- Verified that the application works correctly with both valid and
invalid JSON cases
- Confirmed there is no impact on existing functionality
- Tested with strings that start with '[' or '{' but are not valid JSON
to ensure they are handled gracefully
This commit is contained in:
parent
c82a09a15f
commit
107bcfe5bd
2 changed files with 21 additions and 9 deletions
Loading…
Add table
Add a link
Reference in a new issue