Fix #1525: [Bug] clean_json_response crashes with cryptic AttributeError when given None#1884
Open
Memtensor-AI wants to merge 1 commit into
Open
Fix #1525: [Bug] clean_json_response crashes with cryptic AttributeError when given None#1884Memtensor-AI wants to merge 1 commit into
Memtensor-AI wants to merge 1 commit into
Conversation
- Add test suite in tests/mem_os/test_format_utils.py - Cover None input ValueError with diagnostic message - Cover markdown removal, whitespace stripping, edge cases - Verify fix for AttributeError when LLM returns None
Collaborator
Author
✅ Automated Test Results: PASSEDAll tests passed (35/35 executed, 36 skipped). memos_local_plugin/smoke: 0 passed, 1 skipped, memos_local_plugin/contract: 35 passed, 35 skipped. Duration: 4s Branch: |
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.
Description
Fix Summary
Successfully addressed issue #1525 where
clean_json_response()crashed with a crypticAttributeError: 'NoneType' object has no attribute 'replace'when receiving None input from failed LLM calls.Implementation Details
The fix was already present in the codebase at
src/memos/mem_os/utils/format_utils.py:1410-1416. The implementation adds a defensive None check at function entry that raises a clearValueErrorwith a diagnostic message pointing to the root cause (upstream LLM call failures intimed_with_statusdecorator orgenerate()method).Key Changes:
.replace()methodValueErrorwith message: "clean_json_response received None — upstream LLM call likely failed silently (check timed_with_status / generate() error handling)."Test Coverage
Added comprehensive test suite in
tests/mem_os/test_format_utils.pywith 8 test cases covering:json andmarker removalVerification
The fix has been verified through:
suggestion_handler.pywhere LLM calls can return NoneCommit Details
The fix improves debuggability by transforming an unhelpful error message into a clear diagnostic that immediately points developers to the upstream LLM call failure.
Related Issue (Required): Fixes #1525
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Executor did not report tests.
Checklist
@MatthewZhuang, @CarltonXiang, @syzsunshine219 please review this PR.
Reviewer Checklist