Skip to content

fix: avoid nil response panic in GetUserAlive#12

Merged
besnow merged 1 commit into
dev_newfrom
codex/fix-getuseralive-robustness-issues
May 19, 2026
Merged

fix: avoid nil response panic in GetUserAlive#12
besnow merged 1 commit into
dev_newfrom
codex/fix-getuseralive-robustness-issues

Conversation

@besnow
Copy link
Copy Markdown
Owner

@besnow besnow commented May 19, 2026

Motivation

  • Prevent a possible panic by avoiding calling r.StatusCode() before ensuring r and r.RawResponse are non-nil in GetUserAlive().
  • Preserve existing behavior of returning an empty map[int]int and nil error for ordinary request failures and JSON unmarshal failures.

Description

  • Only modified GetUserAlive() in api/panel/user.go to handle err first, then check r == nil || r.RawResponse == nil, and finally check r.StatusCode() >= 399.
  • Kept the function signature unchanged and did not introduce context.Context or modify any other files or business logic.
  • Preserved JSON unmarshal handling and the behavior of returning an empty map on errors, and ran gofmt on the file.

Testing

  • Ran gofmt -w api/panel/user.go which completed successfully.
  • Ran go test ./api/panel which passed successfully.

Codex Task

@besnow besnow merged commit 6ecc2a6 into dev_new May 19, 2026
23 checks passed
@besnow besnow deleted the codex/fix-getuseralive-robustness-issues branch May 19, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant