Skip to content

fix: remove redundant slice in IsGraduate and update golang.org/x/net - #479

Merged
ACaiCat merged 4 commits into
mainfrom
fix/isgraduate-panic
May 12, 2026
Merged

fix: remove redundant slice in IsGraduate and update golang.org/x/net#479
ACaiCat merged 4 commits into
mainfrom
fix/isgraduate-panic

Conversation

@ACaiCat

@ACaiCat ACaiCat commented May 8, 2026

Copy link
Copy Markdown
Member

自查 PR 结构

  • PR 标题符合这个格式: <type>(optional scope): <description>

  • 此 PR 标题的描述以用户为导向,足够清晰,其他人可以理解。

  • 我已经对所有 commit 提供了签名(GPG 密钥签名、SSH 密钥签名)

  • 这个 PR 属于强制变更/破坏性更改

如果是,请在 PR 标题中添加 BREAKING CHANGE 前缀,并在 PR 描述中详细说明。

这个 PR 的类型是什么?

fix

这个 PR 做了什么 / 我们为什么需要这个 PR?

IsGraduate对id切片后传入HasPrefix,导致不合法短id panic

AI调用MCP时传入id不合法会丢panic,干扰上下文
Hmmm,不知道有没有必要在handler校验id长度 (?

govulncheck: 升级golang.org/x/net到v0.53.0解决GO-2026-4918漏洞
lint: 将reflect.Ptr字段替换为reflect.Pointer

(可选)这个 PR 解决了哪个/些 issue?

对 Reviewer 预留的一些提醒

@ACaiCat
ACaiCat requested review from mutezebra and ozline as code owners May 8, 2026 11:23
@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main     #479      +/-   ##
==========================================
- Coverage   62.95%   62.70%   -0.26%     
==========================================
  Files         224      230       +6     
  Lines        5852     6027     +175     
==========================================
+ Hits         3684     3779      +95     
- Misses       2051     2129      +78     
- Partials      117      119       +2     
Flag Coverage Δ
unittest 62.70% <100.00%> (-0.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/utils/id.go 75.00% <100.00%> (ø)

... and 16 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 hardens ID prefix checking in utils.IsGraduate to avoid panics on short/invalid IDs, and updates a few unit tests’ reflection pointer-kind checks to match the current Go toolchain expectations used by this repo.

Changes:

  • Update IsGraduate to use strings.HasPrefix(id, "00000") instead of slicing id[:5] (prevents panic on short IDs).
  • Update test mocks to compare reflect.Value.Kind() against reflect.Pointer when detecting pointer destinations.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/utils/id.go Removes unsafe slicing in IsGraduate to prevent panics on invalid/short IDs.
pkg/db/user/get_relation_test.go Updates reflection kind checks in mocked GORM calls to use reflect.Pointer.
pkg/db/friend_config/get_configs_test.go Updates reflection kind checks in mocked GORM calls to use reflect.Pointer.

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

linrongda
linrongda previously approved these changes May 11, 2026
@linrongda

Copy link
Copy Markdown
Member

ci修一下

@linrongda
linrongda self-requested a review May 11, 2026 13:08
@ACaiCat

ACaiCat commented May 11, 2026

Copy link
Copy Markdown
Member Author

ci修一下

@ACaiCat
ACaiCat requested review from a team and jiuxia211 as code owners May 11, 2026 13:15
@ACaiCat
ACaiCat force-pushed the fix/isgraduate-panic branch from 2cd51ed to 9f94615 Compare May 11, 2026 13:23
@ACaiCat ACaiCat changed the title fix(utils): remove redundant slice in IsGraduate fix: remove redundant slice in IsGraduate and update golang.org/x/net May 11, 2026
@ACaiCat
ACaiCat merged commit 21ae32e into main May 12, 2026
9 checks passed
@ACaiCat
ACaiCat deleted the fix/isgraduate-panic branch May 12, 2026 06:33
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.

3 participants