GeezerVison is showing github.com — fix: MDX 本地图片渲染为 [object Object] + 建议接口 JSON 解析兜底 by longsizhuo · Pull Request #399 · InvolutionHell/involutionhell
Conversation
背景
来自 Vercel 运行时错误巡检(过去 24h):
| 错误 |
次数 |
[docs/resolve] non-redirect status(大量 /docs/.../[object Object]) |
94 次 / 31 个用户 |
/api/suggestions 解析建议 JSON 失败 |
5 次 |
改动
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/suggestions JSON 解析兜底
按生产日志里的真实失败输出逐一处理:
- key 后面跟的是全角冒号:
"action:"...
- 冒号被包进了引号:
"action:"...
- 输出是编号列表,每行一个对象
- 多个
[...] 数组直接拼接
把 key 后面的冒号统一成半角;整体 JSON.parse 失败时,再逐个提取 {...} 对象。5 个生产样本全部能正确解析,字符串值里本来就有的全角冒号不会被改动。
3. docs/resolve 日志降噪
后端返回 404 表示"这个路径没有历史重命名映射",是正常结论,不再用 console.error 记录。403(CF 拦截)和 5xx 仍然按错误记录,不会藏掉真正的后端故障。
验证
tsc --noEmit 通过
- eslint 无新增问题;prettier 通过
- pre-commit:vitest 89/89 通过,图片检查和 lockfile 检查通过
🤖 Generated with Claude Code
https://claude.ai/code/session_014zBGrQgQnx1eLA9jQfSJWD
Generated by Claude Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
- 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 <[email protected]>
Claude-Session: https://claude.ai/code/session_014zBGrQgQnx1eLA9jQfSJWD
vercel
Bot
commented
Sep 29, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This branch was successfully deployed
2 active
deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.