-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
📋 Description\nMultiple AI service methods and dataset processing code call (or assume parsed JSON) without a robust fallback when the content is malformed or not JSON. This may cause runtime errors or unexpected behavior if external responses are not valid JSON.\n\n---\n\n## 🔄 Steps to Reproduce\n1. Mock an AI provider to return malformed JSON or a string that is not JSON.\n2. Call the endpoint that uses the AI service (e.g., ChartWithGroq / GenerateText endpoints).\n3. Observe unhandled parsing errors or exceptions.\n\n---\n\n## ✅ Expected Behavior\nThe code should safely attempt to parse JSON and fall back to returning the raw string or a safe default when parsing fails. It should also log diagnostics and avoid throwing unhandled parse exceptions.\n\n---\n\n## 🚫 Actual Behavior\n- Several places perform or assume is JSON and call directly.\n\nAffected files (initial scan):\n- \n- \n- \n- \n\n---\n\n## ✅ Fix / Recommendation\nIntroduce a single utility that returns a fallback value when parsing fails, log the error for diagnostics, and use it across the affected services. Add unit tests for the utility and update services to use it.\n\n---\n\n## 💻 Environment\n- Repo: main branch\n\n---\n\nI will open a PR from my fork implementing this fix with tests. If you need more details or would like to handle this differently, please let me know.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels