Skip to content

Show error on auth reset with no users configured#560

Merged
sairon merged 1 commit into
masterfrom
handle-auth-reset-no-users
Apr 9, 2025
Merged

Show error on auth reset with no users configured#560
sairon merged 1 commit into
masterfrom
handle-auth-reset-no-users

Conversation

@sairon
Copy link
Copy Markdown
Member

@sairon sairon commented Apr 9, 2025

Reset on a fresh install shows a rather confusing message:

List of users:
Select a user to reset the password for [1-0]:

When the list is empty, just print an error and quit.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the account reset process so that if no user accounts are configured, a clear error message is displayed and further processing is halted. This update ensures that users receive immediate, actionable feedback, enhancing the overall reliability and user experience of the command.

Reset on a fresh install shows a rather confusing message:

  List of users:
  Select a user to reset the password for [1-0]:

When the list is empty, just print an error and quit.
@sairon sairon requested a review from agners April 9, 2025 13:37
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 9, 2025

📝 Walkthrough

Walkthrough

The changes update the Run function in the authentication reset command by introducing a new error handling block. After calling getUsers(), the function checks if the returned list is empty. If no users exist, it prints an error message ("No users configured."), sets the ExitWithError flag to true, and exits early. The original functionality that lists users remains active when the user list is not empty. No changes were made to exported or public entities.

Changes

File Change Summary
cmd/auth_reset.go Added a check after calling getUsers(): prints an error and sets ExitWithError if no users are configured, preventing further execution.

Sequence Diagram(s)

sequenceDiagram
    participant CMD as authResetCmd.Run
    participant USERS as getUsers()
    
    CMD ->> USERS: Retrieve list of users
    alt Users list is empty
        CMD ->> CMD: Print "No users configured."
        CMD ->> CMD: Set ExitWithError = true
        CMD ->> CMD: Exit function early
    else Users exist
        CMD ->> CMD: Continue with listing users
    end
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7b778a and 8cd4734.

📒 Files selected for processing (1)
  • cmd/auth_reset.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
`*/**(html|markdown|md)`: - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure t...

*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
  • cmd/auth_reset.go
`*/**(html|markdown|md)`: - Use bold to mark UI strings. - If "" are used to mark UI strings, replace them by bold.

*/**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.
  • cmd/auth_reset.go
`*/**(html|markdown|md)`: - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

*/**(html|markdown|md): - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"

  • cmd/auth_reset.go
`*/**(html|markdown|md)`: - Use sentence-style capitalization also in headings.

*/**(html|markdown|md): - Use sentence-style capitalization also in headings.

  • cmd/auth_reset.go
`*/**(html|markdown|md)`: do not comment on HTML used for icons

*/**(html|markdown|md): do not comment on HTML used for icons

  • cmd/auth_reset.go
`*/**(html|markdown|md)`: Avoid flagging inline HTML for embedding videos in future reviews for this repository.

*/**(html|markdown|md): Avoid flagging inline HTML for embedding videos in future reviews for this repository.

  • cmd/auth_reset.go
🧬 Code Graph Analysis (1)
cmd/auth_reset.go (1)
cmd/root.go (1)
  • ExitWithError (26-26)
🔇 Additional comments (1)
cmd/auth_reset.go (1)

112-116: Well-implemented error handling for empty user list.

This is a good improvement that properly handles the case where no users are configured. Instead of showing a confusing "List of users:" message with no options to select from, it now clearly informs the user about the situation and terminates the command. The error handling pattern (setting ExitWithError and returning) is consistent with other error paths in this file.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Member

@agners agners left a comment

Choose a reason for hiding this comment

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

LGTM!

@sairon sairon merged commit 18d67f3 into master Apr 9, 2025
9 checks passed
@sairon sairon deleted the handle-auth-reset-no-users branch April 9, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants