fix: MDX 本地图片渲染为 [object Object] + 建议接口 JSON 解析兜底 - #399
Merged
Merged
Conversation
- mdx-components: remark-image 把本地相对路径图片编译成静态 import, src 是 StaticImageData 对象,原生 <img> 直接透传导致 src="[object Object]", 文档内本地图片全部裂图,并触发大量 /docs/.../[object Object] 404 - /api/suggestions: 归一化 key 后的全角冒号与缺失引号;整体 JSON.parse 失败时逐个提取对象,兼容编号列表、多数组拼接等 LLM 输出 - docs/resolve: 后端 404(无历史映射)是正常结论,不再按 error 记录; 403 / 5xx 仍记录 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014zBGrQgQnx1eLA9jQfSJWD
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
longsizhuo
marked this pull request as ready for review
September 29, 2026 14:16
This branch was successfully deployed
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.
背景
来自 Vercel 运行时错误巡检(过去 24h):
[docs/resolve] non-redirect status(大量/docs/.../[object Object])/api/suggestions解析建议 JSON 失败改动
1. 文档本地图片全部裂图(用户可见的 bug)
remark-image会把[](./xxx.png)编译成静态 import,src是StaticImageData对象。mdx-components.tsx的自定义img直接把对象透传给原生<img>,结果渲染成src="[object Object]"。浏览器按相对路径去请求/docs/.../[object Object],这就是那 94 次 404 的主要来源。生产环境实测:
/zh/docs/learn/ai/recommender-systems/wangshusen_recommend_note/wangshusen_recommend_note_retrieval一个页面上就有 33 张图 是src="[object Object]"。修复方式:对象形式的
src取.src,字符串形式保持不变。2.
/api/suggestionsJSON 解析兜底按生产日志里的真实失败输出逐一处理:
"action:"..."action:"...[...]数组直接拼接把 key 后面的冒号统一成半角;整体
JSON.parse失败时,再逐个提取{...}对象。5 个生产样本全部能正确解析,字符串值里本来就有的全角冒号不会被改动。3.
docs/resolve日志降噪后端返回 404 表示"这个路径没有历史重命名映射",是正常结论,不再用
console.error记录。403(CF 拦截)和 5xx 仍然按错误记录,不会藏掉真正的后端故障。验证
tsc --noEmit通过🤖 Generated with Claude Code
https://claude.ai/code/session_014zBGrQgQnx1eLA9jQfSJWD
Generated by Claude Code