Skip to content

fix: errcheck(e.Start / c.JSON)を解消 (#316)#372

Merged
taminororo merged 1 commit into
developfrom
fix/316-errcheck-server-controller
Jun 21, 2026
Merged

fix: errcheck(e.Start / c.JSON)を解消 (#316)#372
taminororo merged 1 commit into
developfrom
fix/316-errcheck-server-controller

Conversation

@taminororo

@taminororo taminororo commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

errcheck が指摘していた3件(e.Start 1件 + c.JSON 2件)を解消する。これで errcheck は全体で 0 件#358 / #359 と合わせて errcheck 完了)。

Close #316

変更

server.go: サーバー起動エラーの処理

// Before
e.Start(":1234")
// After
e.Logger.Fatal(e.Start(":1234"))

起動失敗(ポート競合など)は致命的なので、ログを出してプロセス終了する Echo の定石に統一。

user_controller.go GetCurrentUser: レスポンス書き込みエラーの伝播

// Before(c.JSON のエラーを捨て、さらに return err で二重書き込み)
if err != nil {
    c.JSON(http.StatusNotFound, user)
    return err
} else {
    c.JSON(http.StatusOK, user)
    return nil
}
// After(c.JSON の結果をそのまま return)
if err != nil {
    return c.JSON(http.StatusNotFound, user)
}
return c.JSON(http.StatusOK, user)

c.JSON の error を Echo に伝播。あわせて「c.JSON を裸で呼んだ後 return err」していた二重書き込みも解消。エラー時は 404 + user ボディを返す挙動。

スコープ外(別途)

  • c.Request().Header["Access-Token"][0] はヘッダ不在で panic しうる(.Get("Access-Token") が安全)。errcheck の対象外のため本PRでは触れていない。

Test plan

  • cd api && go build ./... 通過
  • golangci-lint run --enable-only errcheck0 issues

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • サーバー起動失敗時のエラーハンドリングを改善しました。
    • ユーザー関連APIのエラーレスポンスの一貫性を向上させました。

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

More reviews will be available in 46 minutes and 45 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 refill rate.

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b53fec9e-9e69-4d9f-b4bd-b630acdd636a

📥 Commits

Reviewing files that changed from the base of the PR and between 5ed4a05 and 2100f9a.

📒 Files selected for processing (1)
  • .github/workflows/lint.yml
📝 Walkthrough

Walkthrough

golangci-lint(errcheck)の指摘を解消する修正。server.go でサーバー起動失敗を e.Logger.Fatal 経由で致命的エラーとして扱うよう変更し、user_controller.goGetCurrentUserc.JSON の戻り値を直接 return する形に整理した。

Changes

errcheck エラー未処理の解消

Layer / File(s) Summary
サーバー起動エラーのフェイタルログ処理
api/lib/externals/server/server.go
import 順序(net/httpos)を入れ替え、e.Start(":1234") の呼び出しを e.Logger.Fatal(e.Start(":1234")) に変更。起動失敗時に Echo のロガー経由でプロセスを終了させる。
GetCurrentUser の c.JSON エラー戻り値処理
api/lib/internals/controller/user_controller.go
if err != nil 分岐内の c.JSON(...) + return err/nil の構造を return c.JSON(...) に変更。c.JSON のエラーを Echo のエラーハンドラに委ねる形に整理。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 エラーを握りつぶさず、
ちゃんと返すよ、ぴょんと!
Logger.Fatal で叫んで、
return c.JSON でお返事 🌸
コードはすっきり、うさぎも満足 ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRのタイトルは修正内容(errcheckの3件を解消)を明確かつ簡潔に説明しており、変更内容と完全に一致している。
Description check ✅ Passed PR説明は対応Issue、変更内容、テスト方法が含まれており、テンプレートの主要な要素を満たしている。詳細な説明でcontext も十分。
Linked Issues check ✅ Passed PR変更はIssue #316の3件全て(server.go:42のe.Start、user_controller.go:100/103のc.JSON)に対応し、errcheck違反を完全に解消している。
Out of Scope Changes check ✅ Passed PR説明で明示されているように、user_controller.goの別のセキュリティ問題はスコープ外とされており、変更内容はIssue #316の3件に限定されている
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/316-errcheck-server-controller

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 and usage tips.

@taminororo taminororo force-pushed the fix/316-errcheck-server-controller branch from 2100f9a to 5ed4a05 Compare June 21, 2026 19:21
@taminororo taminororo merged commit e7941b1 into develop Jun 21, 2026
1 check passed
@taminororo taminororo deleted the fix/316-errcheck-server-controller branch June 21, 2026 19:24
taminororo added a commit that referenced this pull request Jun 21, 2026
CodeRabbit は root 起点で golangci-lint を実行し api/ サブモジュールに
対して動かせない(#373)。回数無制限・クレジット非依存の GitHub Actions で
working-directory: api 実行に置き換える。

- 既存 lint 負債(約74件)で全PRが赤くならないよう only-new-issues: true で
  「PRで新規に増えた指摘」だけを対象にする
- golangci-lint v2 対応のため action は v7、version は v2.12
- PR #372 のブランチ上で実地検証済み(golangci-lint 2.12.2 が api/ で動作、
  --new-from-patch で新規0件 → 緑、45秒で完走)

Refs #373
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.

[Go static] errcheck: エラー未処理の解消 (e.Start / c.JSON 3件)

1 participant