Skip to content

fix(leaderboard): 日志区分 null 和 object (Copilot CR PR #328)#329

Merged
longsizhuo merged 1 commit intomainfrom
fix/leaderboard-log-null-kind
Apr 27, 2026
Merged

fix(leaderboard): 日志区分 null 和 object (Copilot CR PR #328)#329
longsizhuo merged 1 commit intomainfrom
fix/leaderboard-log-null-kind

Conversation

@longsizhuo
Copy link
Copy Markdown
Member

CR

PR #328 Copilot 反馈:JS 历史包袱 `typeof null === "object"`,fallback 兜底分支日志写 `kind=object` 时排查者会误以为是普通对象绕半天。

改动

单独识别 null:
```js
const kind = parsed === null ? "null" : typeof parsed;
```

实测

  • `null` → `kind=null`
  • `{...}` → `kind=object`
  • `"str"` → `kind=string`

Copilot CR (PR #328)
JS 历史包袱:typeof null === "object"。之前 fallback 兜底分支日志写
"kind=object",遇到既有内容是 null 时排查者会误以为是个普通对象,绕半天。
单独识别 null,日志输出 kind=null。

实测三种情况日志输出:
- null    → kind=null
- {...}   → kind=object
- "str"   → kind=string
Copilot AI review requested due to automatic review settings April 27, 2026 16:55
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2026

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

Project Deployment Actions Updated (UTC)
involutionhell-github-io Building Building Preview, Comment Apr 27, 2026 4:55pm
website-preview Building Building Preview, Comment Apr 27, 2026 4:55pm

@longsizhuo longsizhuo merged commit d9f77b8 into main Apr 27, 2026
6 of 8 checks passed
@longsizhuo longsizhuo deleted the fix/leaderboard-log-null-kind branch April 27, 2026 16:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the diagnostic logging in the leaderboard generator’s fallback path by distinguishing null from ordinary objects when previously parsed JSON is not an array. This helps operators/debuggers avoid being misled by JavaScript’s typeof null === "object" behavior when investigating invalid existing generated/site-leaderboard.json contents.

Changes:

  • Introduce a kind value that reports "null" when parsed === null, otherwise uses typeof parsed.
  • Update the fallback warning log to print kind=... instead of typeof=... for non-array existing JSON.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants