fix(utils): recover JSON objects after leading whitespace#5766
Conversation
|
Hi @VectorPeak, thank you for your first Pull Request! 🎉 🙌 Join Developer CommunityThanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page: We truly appreciate your enthusiasm—and look forward to your future contributions! 😊 We'll review your PR soon. |
ccdb659 to
a383e60
Compare
|
The test fails due to ACP breaking changes, which has been fixed in #5798 |
Welcome to QwenPaw! 🎉Thank you @VectorPeak for your first contribution! Your PR has been merged. 🚀 We'd love to give you a shout-out in our release notes! If you're comfortable sharing, please reply to this comment with your social media handles using the format below:
Thanks again for helping make QwenPaw better! |
commit e936dd4 Author: Qin Xiaoming <xiaoming.qxm@gmail.com> Date: Wed Jul 8 21:21:25 2026 +0800 fix(mcp): apply runtime approval level to driver policy (agentscope-ai#5864) Co-authored-by: Xiaoming Qin <xiaoming.qxm@alibaba-inc.com> commit adceab9 Author: lalaliat <78087788+lalaliat@users.noreply.github.com> Date: Wed Jul 8 17:36:13 2026 +0800 feat(cron): add tool safety toggle for cron jobs to control approval … (agentscope-ai#5847) commit 717aa4d Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Wed Jul 8 16:35:14 2026 +0800 feat(console): enhance approval card UI and UX (agentscope-ai#5855) commit 2cf61c5 Author: Keefe Wong <595751021@qq.com> Date: Wed Jul 8 16:21:45 2026 +0800 feat(console): enable long text upload (agentscope-ai#5854) commit 691724c Author: qbc <qianbingchen.qbc@alibaba-inc.com> Date: Wed Jul 8 15:19:23 2026 +0800 fix(runtime): persist interrupted turn state and suppress empty cancel messages (agentscope-ai#5838) commit 1178097 Author: zhijianma <zhijian.mzj@alibaba-inc.com> Date: Wed Jul 8 15:18:50 2026 +0800 Revert "feat(console): enable long text upload regression config and optimize message rendering (agentscope-ai#5845)" (agentscope-ai#5851) commit 5d335fe Author: hehuang139 <ox48@qq.com> Date: Wed Jul 8 14:58:03 2026 +0800 fix(providers): retry streaming OpenAI APIError with body status codes (agentscope-ai#5799) commit c1ff7bc Author: Syed Osama Ali Shah <86572800+Osamaali313@users.noreply.github.com> Date: Wed Jul 8 09:57:52 2026 +0300 fix(agents): stop dropping self-paired tool messages during sanitation (agentscope-ai#5792) commit a3be71b Author: Jinglin Peng <jlpengcs@gmail.com> Date: Wed Jul 8 14:55:42 2026 +0800 feat: Bundle Node runtime for ACP desktop (agentscope-ai#5814) commit dc4f50c Author: Keefe Wong <595751021@qq.com> Date: Wed Jul 8 14:17:35 2026 +0800 feat(console): enable long text upload regression config and optimize message rendering (agentscope-ai#5845) commit 41755a6 Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Wed Jul 8 11:13:55 2026 +0800 fix(packaging): add static project.urls for GitHub dependency graph (agentscope-ai#5839) commit 69ff31d Author: Irene Lin <yin.lin@alibaba-inc.com> Date: Tue Jul 7 19:53:00 2026 -0700 fix(scroll): protect the active turn, add graduated pressure relief, and make recall failures unmistakable (agentscope-ai#5765) commit 7e86404 Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Tue Jul 7 19:06:30 2026 +0800 chore(version): bump version 2.0.0b4 (agentscope-ai#5837) commit 9dae676 Author: jinliyl <6469360+jinliyl@users.noreply.github.com> Date: Tue Jul 7 16:41:54 2026 +0800 feat(memory): add usage-aware auto search and backend-specific embeddings (agentscope-ai#5820) commit b113eea Author: hongxicheng <1003394729@qq.com> Date: Tue Jul 7 16:37:40 2026 +0800 feat(plugin): support plugin-registered custom channels with schema-driven config UI (agentscope-ai#4693) commit bd8e8b9 Author: zhijianma <zhijian.mzj@alibaba-inc.com> Date: Tue Jul 7 16:26:29 2026 +0800 feat(console, chat): remove default mode of session approval level (agentscope-ai#5832) commit 3dfef8a Author: Mo xi <i@morxi.com> Date: Tue Jul 7 16:09:52 2026 +0800 feat(channels): matrix Add Streaming Mode Like Discord in Matrix (agentscope-ai#5585) commit 88b662f Author: qbc <qianbingchen.qbc@alibaba-inc.com> Date: Tue Jul 7 16:00:09 2026 +0800 fix: sanitize const Schema Field for Gemini Tool Parameters (agentscope-ai#5827) commit ed2fe73 Author: lalaliat <78087788+lalaliat@users.noreply.github.com> Date: Tue Jul 7 15:59:23 2026 +0800 fix(offloader): handle TextBlock objects in offload_tool_result (agentscope-ai#5831) commit 6aff001 Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Tue Jul 7 15:52:15 2026 +0800 feat(coding-mode): allow selecting hidden folders in project browser (agentscope-ai#5828) commit fc7b64e Author: sidiluo <wb-lsd703406@alibaba-inc.com> Date: Tue Jul 7 15:48:15 2026 +0800 docs (website): add new blog (agentscope-ai#5825) commit 5d27c3e Author: Osier-Yi <njuyaoliuyi@gmail.com> Date: Tue Jul 7 15:47:20 2026 +0800 fix (plugin): pet approval bug (agentscope-ai#5830) commit e80860c Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Tue Jul 7 11:54:04 2026 +0800 feat(desktop): hidden 8-click logo gesture to open DevTools (agentscope-ai#5805) commit ae36f4e Author: jinliyl <6469360+jinliyl@users.noreply.github.com> Date: Tue Jul 7 11:47:31 2026 +0800 refactor(memory): simplify auto-memory search state and context handling (agentscope-ai#5815) commit 085d6b2 Author: lalaliat <78087788+lalaliat@users.noreply.github.com> Date: Mon Jul 6 18:18:47 2026 +0800 feat(ci): add QwenPaw review bot (agentscope-ai#5736) commit 58ad207 Author: VectorPeak <garrufariw@gmail.com> Date: Mon Jul 6 17:25:56 2026 +0800 fix(console): route plugin market details through link guard (agentscope-ai#5750) commit c872d7c Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Mon Jul 6 16:00:58 2026 +0800 fix(providers): restore OpenRouter OAuth router dropped in Runtime 2.0 (agentscope-ai#5806) commit 6ff2f02 Author: wangxhu <wananing@outlook.com> Date: Mon Jul 6 15:48:32 2026 +0800 fix(crons): record run timestamps in job timezone (agentscope-ai#5783) commit dd93efb Author: hongxicheng <1003394729@qq.com> Date: Mon Jul 6 15:44:48 2026 +0800 fix(yuanbao): prevent connection failures from empty api_domain and missing proto descriptors (agentscope-ai#5804) commit 6e62383 Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Mon Jul 6 15:22:57 2026 +0800 fix(runtime): remove stale language arg from _process_memory_section call (agentscope-ai#5803) commit c1de2ba Author: Eric Zhu <320302+ekzhu@users.noreply.github.com> Date: Sun Jul 5 23:29:39 2026 -0700 fix(runtime): respect configured workspace prompt files (agentscope-ai#5396) commit 7a0a6bd Author: ManJieqi <40858189+manjieqi@users.noreply.github.com> Date: Mon Jul 6 14:18:05 2026 +0800 fix: add timezone.utc to datetime.fromtimestamp in AgentMdManager (agentscope-ai#5768) commit 6769fba Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Mon Jul 6 13:55:46 2026 +0800 chore(dep): pin ACP version to avoid breaking change (agentscope-ai#5798) commit 91b0b16 Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Mon Jul 6 13:53:50 2026 +0800 Fix: timestamp always visible && Double /api prefix (agentscope-ai#5802) commit 0bc68ed Author: Jinglin Peng <jlpengcs@gmail.com> Date: Mon Jul 6 11:49:56 2026 +0800 feat: switch desktop release to Tauri (agentscope-ai#5734) commit cc6303a Author: VectorPeak <garrufariw@gmail.com> Date: Mon Jul 6 11:48:51 2026 +0800 fix(utils): recover JSON after leading whitespace (agentscope-ai#5766) commit bb313ac Author: Jinglin Peng <jlpengcs@gmail.com> Date: Mon Jul 6 11:31:53 2026 +0800 fix: Include ACP modules in desktop bundle (agentscope-ai#5794) commit 7052644 Author: y1y5 <105190237+y1y5@users.noreply.github.com> Date: Mon Jul 6 10:51:39 2026 +0800 docs(plugins-migration): update v1 to v2 migration guides (agentscope-ai#5752) * docs(plugins-migration): update v1 to v2 migration guides * docs(plugins): address migration guide review comments * add migration guide navigation entry commit f5b1203 Author: mi1k7 <75235876+ustc-mkh@users.noreply.github.com> Date: Sat Jul 4 00:28:22 2026 +0800 feat(sandbox): implement windows native sandbox (agentscope-ai#5525) Co-authored-by: cuiyuebing <cuipaofu@gmail.com> commit f69e61d Author: wangfei010313 <wangfei01219@126.com> Date: Fri Jul 3 18:19:30 2026 +0800 fix(providers): update GitHub Models to new endpoint and support fine-grained PAT (agentscope-ai#5735) commit e228026 Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Fri Jul 3 17:16:00 2026 +0800 feat: add request timeout, retry and AbortSignal support (agentscope-ai#5764) commit 66051e6 Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Fri Jul 3 16:12:46 2026 +0800 refactor(session list): unify session item into SessionItem component(agentscope-ai#5754) commit 856f0ce Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Fri Jul 3 16:11:04 2026 +0800 fix(config): make agent resilient to invalid MCP client config (agentscope-ai#5755) commit 13af342 Author: qbc <qianbingchen.qbc@alibaba-inc.com> Date: Fri Jul 3 15:18:32 2026 +0800 fix: show stream completion time instead of first-chunk time for assistant messages (agentscope-ai#5742) commit 456cbf9 Author: sidiluo <wb-lsd703406@alibaba-inc.com> Date: Fri Jul 3 14:57:40 2026 +0800 fix(website): update blog developer day collection and add blog GA tracking (agentscope-ai#5758) commit 150c1d9 Author: yaozy2020 <88593746+yaozy2020@users.noreply.github.com> Date: Fri Jul 3 14:38:48 2026 +0800 fix(console): mobile chat history panel shows empty session list (agentscope-ai#5744) commit 65b4a04 Author: Runlin Lei <lei_runlin@163.com> Date: Fri Jul 3 14:34:43 2026 +0800 refactor(skill): skill-related UI (agentscope-ai#5753) commit f0cc70f Author: wangfei010313 <wangfei01219@126.com> Date: Fri Jul 3 14:33:58 2026 +0800 feat: add 'none' memory backend to disable long memory system (agentscope-ai#5732) commit f0d2279 Author: Yue Cui <39703217+cuiyuebing@users.noreply.github.com> Date: Fri Jul 3 14:17:27 2026 +0800 chore(version): bump version to 2.0.0b3 (agentscope-ai#5760)
commit b0d9d49 Author: Irene Lin <yin.lin@alibaba-inc.com> Date: Wed Jul 8 20:51:25 2026 -0700 fix(scroll): anchor the live turn with a seam banner in the eviction index (agentscope-ai#5871) commit 9c3a20e Author: Irene Lin <yin.lin@alibaba-inc.com> Date: Wed Jul 8 19:34:25 2026 -0700 fix(scroll): label un-headlined evicted spans in the eviction index (agentscope-ai#5848) commit e936dd4 Author: Qin Xiaoming <xiaoming.qxm@gmail.com> Date: Wed Jul 8 21:21:25 2026 +0800 fix(mcp): apply runtime approval level to driver policy (agentscope-ai#5864) Co-authored-by: Xiaoming Qin <xiaoming.qxm@alibaba-inc.com> commit adceab9 Author: lalaliat <78087788+lalaliat@users.noreply.github.com> Date: Wed Jul 8 17:36:13 2026 +0800 feat(cron): add tool safety toggle for cron jobs to control approval … (agentscope-ai#5847) commit 717aa4d Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Wed Jul 8 16:35:14 2026 +0800 feat(console): enhance approval card UI and UX (agentscope-ai#5855) commit 2cf61c5 Author: Keefe Wong <595751021@qq.com> Date: Wed Jul 8 16:21:45 2026 +0800 feat(console): enable long text upload (agentscope-ai#5854) commit 691724c Author: qbc <qianbingchen.qbc@alibaba-inc.com> Date: Wed Jul 8 15:19:23 2026 +0800 fix(runtime): persist interrupted turn state and suppress empty cancel messages (agentscope-ai#5838) commit 1178097 Author: zhijianma <zhijian.mzj@alibaba-inc.com> Date: Wed Jul 8 15:18:50 2026 +0800 Revert "feat(console): enable long text upload regression config and optimize message rendering (agentscope-ai#5845)" (agentscope-ai#5851) commit 5d335fe Author: hehuang139 <ox48@qq.com> Date: Wed Jul 8 14:58:03 2026 +0800 fix(providers): retry streaming OpenAI APIError with body status codes (agentscope-ai#5799) commit c1ff7bc Author: Syed Osama Ali Shah <86572800+Osamaali313@users.noreply.github.com> Date: Wed Jul 8 09:57:52 2026 +0300 fix(agents): stop dropping self-paired tool messages during sanitation (agentscope-ai#5792) commit a3be71b Author: Jinglin Peng <jlpengcs@gmail.com> Date: Wed Jul 8 14:55:42 2026 +0800 feat: Bundle Node runtime for ACP desktop (agentscope-ai#5814) commit dc4f50c Author: Keefe Wong <595751021@qq.com> Date: Wed Jul 8 14:17:35 2026 +0800 feat(console): enable long text upload regression config and optimize message rendering (agentscope-ai#5845) commit 41755a6 Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Wed Jul 8 11:13:55 2026 +0800 fix(packaging): add static project.urls for GitHub dependency graph (agentscope-ai#5839) commit 69ff31d Author: Irene Lin <yin.lin@alibaba-inc.com> Date: Tue Jul 7 19:53:00 2026 -0700 fix(scroll): protect the active turn, add graduated pressure relief, and make recall failures unmistakable (agentscope-ai#5765) commit 7e86404 Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Tue Jul 7 19:06:30 2026 +0800 chore(version): bump version 2.0.0b4 (agentscope-ai#5837) commit 9dae676 Author: jinliyl <6469360+jinliyl@users.noreply.github.com> Date: Tue Jul 7 16:41:54 2026 +0800 feat(memory): add usage-aware auto search and backend-specific embeddings (agentscope-ai#5820) commit b113eea Author: hongxicheng <1003394729@qq.com> Date: Tue Jul 7 16:37:40 2026 +0800 feat(plugin): support plugin-registered custom channels with schema-driven config UI (agentscope-ai#4693) commit bd8e8b9 Author: zhijianma <zhijian.mzj@alibaba-inc.com> Date: Tue Jul 7 16:26:29 2026 +0800 feat(console, chat): remove default mode of session approval level (agentscope-ai#5832) commit 3dfef8a Author: Mo xi <i@morxi.com> Date: Tue Jul 7 16:09:52 2026 +0800 feat(channels): matrix Add Streaming Mode Like Discord in Matrix (agentscope-ai#5585) commit 88b662f Author: qbc <qianbingchen.qbc@alibaba-inc.com> Date: Tue Jul 7 16:00:09 2026 +0800 fix: sanitize const Schema Field for Gemini Tool Parameters (agentscope-ai#5827) commit ed2fe73 Author: lalaliat <78087788+lalaliat@users.noreply.github.com> Date: Tue Jul 7 15:59:23 2026 +0800 fix(offloader): handle TextBlock objects in offload_tool_result (agentscope-ai#5831) commit 6aff001 Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Tue Jul 7 15:52:15 2026 +0800 feat(coding-mode): allow selecting hidden folders in project browser (agentscope-ai#5828) commit fc7b64e Author: sidiluo <wb-lsd703406@alibaba-inc.com> Date: Tue Jul 7 15:48:15 2026 +0800 docs (website): add new blog (agentscope-ai#5825) commit 5d27c3e Author: Osier-Yi <njuyaoliuyi@gmail.com> Date: Tue Jul 7 15:47:20 2026 +0800 fix (plugin): pet approval bug (agentscope-ai#5830) commit e80860c Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Tue Jul 7 11:54:04 2026 +0800 feat(desktop): hidden 8-click logo gesture to open DevTools (agentscope-ai#5805) commit ae36f4e Author: jinliyl <6469360+jinliyl@users.noreply.github.com> Date: Tue Jul 7 11:47:31 2026 +0800 refactor(memory): simplify auto-memory search state and context handling (agentscope-ai#5815) commit 085d6b2 Author: lalaliat <78087788+lalaliat@users.noreply.github.com> Date: Mon Jul 6 18:18:47 2026 +0800 feat(ci): add QwenPaw review bot (agentscope-ai#5736) commit 58ad207 Author: VectorPeak <garrufariw@gmail.com> Date: Mon Jul 6 17:25:56 2026 +0800 fix(console): route plugin market details through link guard (agentscope-ai#5750) commit c872d7c Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Mon Jul 6 16:00:58 2026 +0800 fix(providers): restore OpenRouter OAuth router dropped in Runtime 2.0 (agentscope-ai#5806) commit 6ff2f02 Author: wangxhu <wananing@outlook.com> Date: Mon Jul 6 15:48:32 2026 +0800 fix(crons): record run timestamps in job timezone (agentscope-ai#5783) commit dd93efb Author: hongxicheng <1003394729@qq.com> Date: Mon Jul 6 15:44:48 2026 +0800 fix(yuanbao): prevent connection failures from empty api_domain and missing proto descriptors (agentscope-ai#5804) commit 6e62383 Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Mon Jul 6 15:22:57 2026 +0800 fix(runtime): remove stale language arg from _process_memory_section call (agentscope-ai#5803) commit c1de2ba Author: Eric Zhu <320302+ekzhu@users.noreply.github.com> Date: Sun Jul 5 23:29:39 2026 -0700 fix(runtime): respect configured workspace prompt files (agentscope-ai#5396) commit 7a0a6bd Author: ManJieqi <40858189+manjieqi@users.noreply.github.com> Date: Mon Jul 6 14:18:05 2026 +0800 fix: add timezone.utc to datetime.fromtimestamp in AgentMdManager (agentscope-ai#5768) commit 6769fba Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Mon Jul 6 13:55:46 2026 +0800 chore(dep): pin ACP version to avoid breaking change (agentscope-ai#5798) commit 91b0b16 Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Mon Jul 6 13:53:50 2026 +0800 Fix: timestamp always visible && Double /api prefix (agentscope-ai#5802) commit 0bc68ed Author: Jinglin Peng <jlpengcs@gmail.com> Date: Mon Jul 6 11:49:56 2026 +0800 feat: switch desktop release to Tauri (agentscope-ai#5734) commit cc6303a Author: VectorPeak <garrufariw@gmail.com> Date: Mon Jul 6 11:48:51 2026 +0800 fix(utils): recover JSON after leading whitespace (agentscope-ai#5766) commit bb313ac Author: Jinglin Peng <jlpengcs@gmail.com> Date: Mon Jul 6 11:31:53 2026 +0800 fix: Include ACP modules in desktop bundle (agentscope-ai#5794) commit 7052644 Author: y1y5 <105190237+y1y5@users.noreply.github.com> Date: Mon Jul 6 10:51:39 2026 +0800 docs(plugins-migration): update v1 to v2 migration guides (agentscope-ai#5752) * docs(plugins-migration): update v1 to v2 migration guides * docs(plugins): address migration guide review comments * add migration guide navigation entry commit f5b1203 Author: mi1k7 <75235876+ustc-mkh@users.noreply.github.com> Date: Sat Jul 4 00:28:22 2026 +0800 feat(sandbox): implement windows native sandbox (agentscope-ai#5525) Co-authored-by: cuiyuebing <cuipaofu@gmail.com> commit f69e61d Author: wangfei010313 <wangfei01219@126.com> Date: Fri Jul 3 18:19:30 2026 +0800 fix(providers): update GitHub Models to new endpoint and support fine-grained PAT (agentscope-ai#5735) commit e228026 Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Fri Jul 3 17:16:00 2026 +0800 feat: add request timeout, retry and AbortSignal support (agentscope-ai#5764) commit 66051e6 Author: zhaozhuang521 <71918264+zhaozhuang521@users.noreply.github.com> Date: Fri Jul 3 16:12:46 2026 +0800 refactor(session list): unify session item into SessionItem component(agentscope-ai#5754) commit 856f0ce Author: Weirui Kuang <39145382+rayrayraykk@users.noreply.github.com> Date: Fri Jul 3 16:11:04 2026 +0800 fix(config): make agent resilient to invalid MCP client config (agentscope-ai#5755) commit 13af342 Author: qbc <qianbingchen.qbc@alibaba-inc.com> Date: Fri Jul 3 15:18:32 2026 +0800 fix: show stream completion time instead of first-chunk time for assistant messages (agentscope-ai#5742) commit 456cbf9 Author: sidiluo <wb-lsd703406@alibaba-inc.com> Date: Fri Jul 3 14:57:40 2026 +0800 fix(website): update blog developer day collection and add blog GA tracking (agentscope-ai#5758) commit 150c1d9 Author: yaozy2020 <88593746+yaozy2020@users.noreply.github.com> Date: Fri Jul 3 14:38:48 2026 +0800 fix(console): mobile chat history panel shows empty session list (agentscope-ai#5744) commit 65b4a04 Author: Runlin Lei <lei_runlin@163.com> Date: Fri Jul 3 14:34:43 2026 +0800 refactor(skill): skill-related UI (agentscope-ai#5753) commit f0cc70f Author: wangfei010313 <wangfei01219@126.com> Date: Fri Jul 3 14:33:58 2026 +0800 feat: add 'none' memory backend to disable long memory system (agentscope-ai#5732) commit f0d2279 Author: Yue Cui <39703217+cuiyuebing@users.noreply.github.com> Date: Fri Jul 3 14:17:27 2026 +0800 chore(version): bump version to 2.0.0b3 (agentscope-ai#5760)

Description
This PR fixes a narrow JSON recovery edge case in
safe_json_loads.What Problem This Solves
safe_json_loadsalready recovered a valid JSON object followed by trailing garbage, such as:However, the same recoverable object previously failed when the content also started with JSON whitespace:
The failure happens only after the primary
json.loads()path rejects the trailing bytes. At that point, the fallback calledJSONDecoder.raw_decode(content)from index0. Unlikejson.loads(), this fallback expects parsing to begin at the JSON document start index, so leading whitespace caused the recovery path to treat an otherwise recoverable object as completely corrupted.This can affect chat session or mission state recovery when a JSON state file is pretty-printed, hand-edited, or partially overwritten with trailing bytes. In that case, data that could otherwise be recovered is treated as unrecoverable and returns
{}.Why This Change Was Made
The fix belongs in
qwenpaw.utils.json_utils.safe_json_loadsbecause that helper is the shared recovery boundary used by chat session loading and mission state loading. Fixing it at the utility layer keeps the behavior consistent for all callers instead of patching one session path.The implementation intentionally stays small: it advances past leading JSON whitespace with
json.decoder.WHITESPACE.match(content, 0).end()before callingraw_decode. This keeps the fallback aligned with JSON whitespace rules without allocating a trimmed copy or accepting broader non-JSON leading text.This PR does not broaden recovery beyond the existing contract. It still leaves these behaviors unchanged:
json.loads()path{}{}Evidence
The regression test covers the exact previously missed case:
Before this change, this input returned
{}because the fallbackraw_decodestarted at index0.After this change, the fallback skips JSON whitespace first and recovers:
{"k": "v"}Possible Call Chain / Impact
Related Issue: N/A
Security Considerations: No auth, env/config boundary, or external input trust policy changes; this narrows a local JSON recovery edge case.
Type of Change
Component(s) Affected
Checklist
pre-commit run --all-fileslocally and it passespytestor as relevant) and they passFor Channel Changes (DingTalk, Lark, QQ, Console, etc.)
./scripts/check-channels.sh(or./scripts/check-channels.sh --changed) and it passestests/contract/channels/test_<channel>_contract.py(REQUIRED)create_instance()with proper channel initializationtests/contract/channels/__init__.py)tests/unit/channels/test_<channel>.pyfor complex internal logicTesting
I ran the focused chat session recovery tests and the adjacent raw-decode utility tests to confirm the broader raw JSON recovery behavior still passes.
Local Verification Evidence
pre-commit run --all-fileshas not been run locally for this PR.Channel-specific checklist items are not applicable because this PR does not change any channel implementation or contract surface.
Additional Notes
The code change is limited to the
raw_decodefallback start index and one regression test. It does not change the normal JSON parsing path or the{}fallback contract for unrecoverable content.