Skip to content

Construct admin links correctly for staging/dev#24

Merged
radon-at-beeper merged 2 commits into
beeperfrom
rr-username-correctly
Mar 18, 2026
Merged

Construct admin links correctly for staging/dev#24
radon-at-beeper merged 2 commits into
beeperfrom
rr-username-correctly

Conversation

@radon-at-beeper

@radon-at-beeper radon-at-beeper commented Mar 18, 2026

Copy link
Copy Markdown

The admin links were wrong for non-production tickets. Also we had no tests so I added some. (Not run automatically by CI yet.)

@coderabbitai

coderabbitai Bot commented Mar 18, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 16d8e462-662c-4108-b682-4cbe1b591b2a

📥 Commits

Reviewing files that changed from the base of the PR and between e531c7c and b8433a4.

📒 Files selected for processing (1)
  • submit_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • submit_test.go

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Enhanced user identification that generates an admin link for verified accounts.
    • Improved report title generation: uses the first line of user input or "Untitled report" and truncates to 200 characters.
  • Tests

    • Added table-driven tests covering username extraction, admin link generation, and verification outcomes.

Walkthrough

getUsernameFromPayload in submit.go now returns (username, adminLink, isVerified); a global regex parses user_id to build adminLink. buildGenericIssueRequest uses adminLink for the "User Admin" link. New table-driven tests validate username, adminLink, and verification extraction.

Changes

Cohort / File(s) Summary
User identification & request building
submit.go
Changed getUsernameFromPayload signature to return (username, adminLink, isVerified). Added userIDRegexp and logic to derive adminLink from user_id (with username fallback). Updated buildGenericIssueRequest to consume adminLink. Adjusted title generation to use the first line of user text and truncate to 200 chars.
Unit tests
submit_test.go
Added table-driven tests (TestGetUsernameFromPayload) covering multiple payload cases and asserting returned username, adminLink, and isVerified.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title accurately describes the main change: fixing admin link construction for staging/dev environments, which aligns with the core modifications to getUsernameFromPayload and adminLink handling.
Description check ✅ Passed The description is directly related to the changeset, explaining that admin links were incorrect for non-production tickets and tests were added to address this issue.

✏️ 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 rr-username-correctly
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting to automatically approve the review once all CodeRabbit's comments are resolved.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
submit_test.go (1)

38-57: Missing name field in test cases.

These two test cases are missing the name field, which will result in empty test names in t.Run(""). This makes test output harder to interpret when debugging failures.

Suggested fix
 	{
+		name: "staging domain",
 		in: map[string]string{
 			"user_id": "@bender:beeper-staging.com",
 		},
 		out: usernameOutput{
 			username:   "bender:beeper-staging.com",
 			adminLink:  "https://admin.beeper-staging.com/user/bender",
 			isVerified: true,
 		},
 	},
 	{
+		name: "unknown domain fallback",
 		in: map[string]string{
 			"user_id": "@bender:beeper-anywhere.com",
 		},
 		out: usernameOutput{
 			username:   "bender:beeper-anywhere.com",
 			adminLink:  "https://admin.beeper.com/user/bender:beeper-anywhere.com",
 			isVerified: true,
 		},
 	},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@submit_test.go` around lines 38 - 57, The two table-driven test entries are
missing the test-case `name` field which causes t.Run("") to show empty names;
update each of those test-case literals (the ones with in:
map[string]string{"user_id": ...} and out: usernameOutput{...}) to include a
descriptive `name` string (e.g., "beeper-staging verified" and "beeper-anywhere
verified") so t.Run uses a meaningful label when running the test; ensure the
`name` key matches the test-case struct field used by the test harness.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@submit_test.go`:
- Around line 38-57: The two table-driven test entries are missing the test-case
`name` field which causes t.Run("") to show empty names; update each of those
test-case literals (the ones with in: map[string]string{"user_id": ...} and out:
usernameOutput{...}) to include a descriptive `name` string (e.g.,
"beeper-staging verified" and "beeper-anywhere verified") so t.Run uses a
meaningful label when running the test; ensure the `name` key matches the
test-case struct field used by the test harness.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 62cf67d2-749f-453d-b322-a73bf420e97a

📥 Commits

Reviewing files that changed from the base of the PR and between a2107c5 and e531c7c.

📒 Files selected for processing (2)
  • submit.go
  • submit_test.go
📜 Review details
🔇 Additional comments (3)
submit_test.go (1)

60-72: LGTM!

Good use of table-driven tests. The test function correctly validates all three return values from getUsernameFromPayload, and the struct comparison approach is clean and readable.

submit.go (2)

923-947: LGTM!

The implementation correctly addresses the PR objective. The regex properly captures the username and domain for known Beeper environments, and the fallback path handles unknown domains gracefully. The order of operations (set fallback first, then override if matched) is correct.


1144-1152: LGTM!

The call site is correctly updated to use the new three-value return signature and properly uses adminLink instead of constructing the URL from the username.

@radon-at-beeper radon-at-beeper merged commit 2b3c9fa into beeper Mar 18, 2026
3 checks passed
@radon-at-beeper radon-at-beeper deleted the rr-username-correctly branch March 18, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants