GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: MDX 本地图片渲染为 [object Object] + 建议接口 JSON 解析兜底 by longsizhuo · Pull Request #399 · InvolutionHell/involutionhell

Conversation

@longsizhuo

@longsizhuo longsizhuo commented Sep 29, 2026

Copy link
Copy Markdown
Member

背景

来自 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.

All reactions
@claude
fix: 修复 MDX 本地图片渲染为 [object Object] 及建议接口 JSON 解析失败
e7896a6
- 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

vercel Bot commented Sep 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
involutionhell-github-io Ready Ready Preview Sep 29, 2026 12:41pm UTC
website-preview Ready Ready Preview Sep 29, 2026 12:41pm UTC
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vercel
vercel Bot deployed to Preview – involutionhell-github-io September 29, 2026 12:41
View deployment
@vercel
vercel Bot deployed to Preview – website-preview September 29, 2026 12:41
View deployment
@longsizhuo
longsizhuo marked this pull request as ready for review September 29, 2026 14:16
Copilot AI balanced review requested due to automatic review settings September 29, 2026 14:16
Copilot AI reviewed Sep 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

All reactions
@longsizhuo
longsizhuo merged commit 3eac782 into main Sep 29, 2026
9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@longsizhuo longsizhuo mentioned this pull request Oct 2, 2026
fix(suggestions): 兼容 LLM 输出中字段/对象间的全角逗号 #401
Draft

This branch was successfully deployed

2 active deployments
Preview – website-preview — e7896a66 Deployed Sep 29, 2026 by vercel[bot]
View deployment
Preview – involutionhell-github-io — e7896a66 Deployed Sep 29, 2026 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@longsizhuo @claude
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.