Skip to content

fix: panic when aborting on tenant selection#326

Merged
AvitalTamir merged 1 commit intomainfrom
avital/core-6890-cli-panic-when-aborting-during-tenant-choice-dialog
Oct 8, 2025
Merged

fix: panic when aborting on tenant selection#326
AvitalTamir merged 1 commit intomainfrom
avital/core-6890-cli-panic-when-aborting-during-tenant-choice-dialog

Conversation

@AvitalTamir
Copy link
Contributor

@AvitalTamir AvitalTamir commented Oct 8, 2025

fix panic when hitting ctrl-c during tenant selection.

before:
Screenshot 2025-10-08 at 10 12 59

after:
Screenshot 2025-10-08 at 10 13 08

Summary by CodeRabbit

  • Bug Fixes
    • Improved login tenant selection handling. The app now clearly reports when tenant selection is canceled and when an invalid tenant is chosen, instead of failing ambiguously.
    • Enhanced error messages during login to guide users in correcting selection issues and retrying smoothly.

@coderabbitai
Copy link

coderabbitai bot commented Oct 8, 2025

Walkthrough

Adds explicit validation in cmd/login.go’s fetchTenant: handle empty selection as cancellation error, reject unknown tenant names, and return the tenant only when found.

Changes

Cohort / File(s) Summary
Login tenant validation
cmd/login.go
Replaced direct map return with guarded checks: error on empty selection, error on unknown tenant, success when tenant exists.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant CLI as CLI (login)
  participant FT as fetchTenant
  participant TM as tenantsByName

  User->>CLI: Initiate login & select tenant
  CLI->>FT: fetchTenant(tenantName, tenantsByName)
  alt tenantName empty
    FT-->>CLI: error "tenant selection cancelled"
    CLI-->>User: Inform cancellation
  else tenantName not in TM
    FT->>TM: Lookup tenantName
    TM-->>FT: nil
    FT-->>CLI: error "invalid tenant selected"
    CLI-->>User: Inform invalid selection
  else tenantName exists
    FT->>TM: Lookup tenantName
    TM-->>FT: tenant
    FT-->>CLI: tenant, nil
    CLI-->>User: Proceed with selected tenant
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 succinctly identifies the main change—preventing a panic when aborting tenant selection—and clearly conveys the PR’s intent in a concise manner.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch avital/core-6890-cli-panic-when-aborting-during-tenant-choice-dialog

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between be22f05 and 980ca50.

📒 Files selected for processing (1)
  • cmd/login.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: goreleaser
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
cmd/login.go (1)

118-127: Fix correctly handles cancellation and invalid selections.

The explicit validation prevents the panic by:

  • Catching empty string from Ctrl-C (cancellation)
  • Verifying tenant exists before map access

Error messages are clear and actionable.


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

@AvitalTamir AvitalTamir merged commit 6ce902f into main Oct 8, 2025
5 checks passed
@AvitalTamir AvitalTamir deleted the avital/core-6890-cli-panic-when-aborting-during-tenant-choice-dialog branch October 8, 2025 07:23
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