fix(leaderboard): 日志区分 null 和 object (Copilot CR PR #328)#329
Merged
longsizhuo merged 1 commit intomainfrom Apr 27, 2026
Merged
fix(leaderboard): 日志区分 null 和 object (Copilot CR PR #328)#329longsizhuo merged 1 commit intomainfrom
longsizhuo merged 1 commit intomainfrom
Conversation
Copilot CR (PR #328) JS 历史包袱:typeof null === "object"。之前 fallback 兜底分支日志写 "kind=object",遇到既有内容是 null 时排查者会误以为是个普通对象,绕半天。 单独识别 null,日志输出 kind=null。 实测三种情况日志输出: - null → kind=null - {...} → kind=object - "str" → kind=string
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
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
kindvalue that reports"null"whenparsed === null, otherwise usestypeof parsed. - Update the fallback warning log to print
kind=...instead oftypeof=...for non-array existing JSON.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
CR
PR #328 Copilot 反馈:JS 历史包袱 `typeof null === "object"`,fallback 兜底分支日志写 `kind=object` 时排查者会误以为是普通对象绕半天。
改动
单独识别 null:
```js
const kind = parsed === null ? "null" : typeof parsed;
```
实测