Skip to content

fix: use field access for Errno.Status and Errno.Message in response.JSON - #141

Merged
dongjiang1989 merged 2 commits into
masterfrom
add-test
Jun 29, 2026
Merged

fix: use field access for Errno.Status and Errno.Message in response.JSON #141
dongjiang1989 merged 2 commits into
masterfrom
add-test

Conversation

@dongjiang1989

@dongjiang1989 dongjiang1989 commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved error response generation to use direct error details when building JSON responses.
    • Internal server errors now return the expected status and message more reliably.

Signed-off-by: dongjiang <dongjiang1989@126.com>
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@dongjiang1989, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 43 minutes and 17 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d80d3273-7699-431d-ba1e-b6ab434b769e

📥 Commits

Reviewing files that changed from the base of the PR and between 7592357 and 6850045.

⛔ Files ignored due to path filters (1)
  • scripts/go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • pkg/response/response.go
  • scripts/go.mod
  • scripts/tools.go
📝 Walkthrough

Walkthrough

In pkg/response/response.go, the JSON() function's error handling for *errno.Errno is updated to access Status and Message as struct fields rather than calling them as methods, for both the matched error and the InternalServerError fallback.

Changes

Response errno field access

Layer / File(s) Summary
Direct field access in JSON()
pkg/response/response.go
Replaces nerr.Status()/nerr.Message() method calls with nerr.Status/nerr.Message field access, and applies the same change to errno.InternalServerError in the fallback path.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A rabbit hops through fields of code,
No methods needed on this road.
Just fields direct, no parens call,
.Status, .Message — that's all!
🐇 Simple, clean, and standing tall.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and clearly describes the main code change in response.JSON.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the JSON response handling in pkg/response/response.go to access the Status and Message fields of errno.Errno directly instead of calling their getter methods. The review points out a potential nil pointer dereference panic if errors.As matches a typed nil pointer, and suggests adding a nil check for nerr before accessing its fields.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/response/response.go
- Use errors.AsType generic syntax instead of errors.As for modernize linter
- Access Errno.Status and Errno.Message as fields instead of method calls
- Remove unused mdox from scripts/tools.go to fix dependency conflicts

Signed-off-by: dongjiang <dongjiang1989@126.com>
@dongjiang1989
dongjiang1989 merged commit c093760 into master Jun 29, 2026
15 checks passed
@dongjiang1989
dongjiang1989 deleted the add-test branch June 29, 2026 02:26
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