Repository navigation
Conversation
clean_json_response replaced every triple-backtick run in the response, so JSON string values that themselves contain fenced code (common when an LLM returns content with markdown snippets) were silently corrupted before json.loads. Strip only an opening fence (with its optional info string) at the very start and a closing fence at the very end. Red/green verified: the new test fails against the old implementation (interior fences removed) and passes with the fix. Signed-off-by: simpleqt <89645338+simpleqt@users.noreply.github.com>
Collaborator
🤖 Open Code ReviewTarget: PR #2421 ✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). Generated by cloud-assistant via Open Code Review. |
Collaborator
✅ Automated Test Results: PASSEDAll tests passed (12/12 executed). memos_python_core/changed-repo-python: 12/12. Duration: 8s Branch: |
Contributor
|
This PR has been automatically marked as stale due to inactivity. |
Contributor
|
This PR has been automatically closed due to inactivity. |
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
Fixes #2420
clean_json_responsestripped markdown fences with a globalreplace("```", ""), so JSON string values containing fenced code were silently corrupted beforejson.loadsinapi/handlers/chat_handler.pyandapi/handlers/suggestion_handler.py:Implementation: strip only an opening fence —
^```[^\n]*\n?(covers the optionaljsoninfo string) — and a closing fence —\n?```\s*$— via a single anchoredre.sub. Interior occurrences are untouched. No dependency changes.Type of change
How Has This Been Tested?
Added four pytest cases in
tests/mem_os/test_format_utils.py: interior fences preserved (red/green discriminator — fails against unpatched main), plain fences still stripped, fence-less input unchanged, and opening-fence-only input.ruff checkandruff format --checkpass on both touched files.Checklist