Skip to content

feat: add goleak, guard InitRollbar on empty token#29

Merged
ankurs merged 2 commits intomainfrom
feat/rollbar-guard-goleak
Apr 9, 2026
Merged

feat: add goleak, guard InitRollbar on empty token#29
ankurs merged 2 commits intomainfrom
feat/rollbar-guard-goleak

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented Apr 9, 2026

Summary

  • Add goleak.VerifyTestMain to catch goroutine leaks in tests
  • Guard InitRollbar() with early return when token is empty, preventing rollbarInited=true with no token configured

Test plan

  • make test passes with goleak enabled
  • make lint clean

Summary by CodeRabbit

  • Bug Fixes

    • Notification service now safely skips external error-reporting initialization when credentials are missing.
  • Chores

    • Added goroutine leak detection to the test suite to catch concurrency issues.
    • Updated build toolchain declaration and bumped an internal test dependency for improved testing stability.

- Add goleak.VerifyTestMain to catch goroutine leaks in tests
- Guard InitRollbar with early return when token is empty, preventing
  rollbarInited=true with no token configured
Copilot AI review requested due to automatic review settings April 9, 2026 05:23
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 76f7413b-0924-4de9-a407-74af7a5ee9df

📥 Commits

Reviewing files that changed from the base of the PR and between 28c1d97 and bf9fb98.

📒 Files selected for processing (2)
  • go.mod
  • notifier/notifier.go
✅ Files skipped from review due to trivial changes (2)
  • go.mod
  • notifier/notifier.go

📝 Walkthrough

Walkthrough

Adds goleak-based goroutine leak detection to tests, adds go.uber.org/goleak to go.mod, and makes InitRollbar(token, env string) return early when token is empty to avoid initializing Rollbar.

Changes

Cohort / File(s) Summary
Dependency Management
go.mod
Bumped toolchain entry and added go.uber.org/goleak v1.3.0 as a direct requirement.
Test Infrastructure
goleak_test.go
Added func TestMain(m *testing.M) that calls goleak.VerifyTestMain(m) to enable goroutine-leak verification around tests.
Notifier Logic
notifier/notifier.go
InitRollbar(token, env string) now checks for empty token and returns early without calling Rollbar setup when empty.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I hopped through tests with a careful peek,

Goleak on patrol for each stray leak.
Tokens checked early—no Rollbar surprise,
Soft thumps, neat code, and wide-open eyes.
🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: adding goleak dependency and guarding InitRollbar against empty tokens.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rollbar-guard-goleak

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds test-time goroutine leak detection and tightens Rollbar initialization behavior in the notifier package to avoid marking Rollbar as initialized when no token is configured.

Changes:

  • Add an early return in InitRollbar() when the token is empty.
  • Add a package-level TestMain using goleak.VerifyTestMain (currently for the root errors package only).
  • Add go.uber.org/goleak as a module dependency.

Reviewed changes

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

File Description
notifier/notifier.go Guards Rollbar initialization to avoid enabling Rollbar behavior when token is empty.
goleak_test.go Introduces TestMain to run goleak verification for the errors package tests.
go.mod Adds go.uber.org/goleak dependency for leak detection in tests.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@notifier/notifier.go`:
- Around line 136-138: When InitRollbar(token, env) receives an empty token it
currently returns early without resetting notifier state; update InitRollbar to
explicitly set rollbarInited = false (and clear any Rollbar client/state if
present) before returning when token == "" so prior successful inits are fully
disabled and the notifier state reflects that Rollbar is off.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 20a78d8d-4225-419a-bb0e-1bc79a8dc451

📥 Commits

Reviewing files that changed from the base of the PR and between 9a99787 and 28c1d97.

📒 Files selected for processing (3)
  • go.mod
  • goleak_test.go
  • notifier/notifier.go

Address review: set rollbarInited=false before early return so
re-calling InitRollbar("", env) properly disables Rollbar after
a previous init.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


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

@ankurs ankurs merged commit 25cb915 into main Apr 9, 2026
11 checks passed
@ankurs ankurs deleted the feat/rollbar-guard-goleak branch April 9, 2026 07:16
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.

2 participants