Skip to content

Potential fixes for 5 code quality findings#63

Merged
Creeper19472 merged 6 commits into
masterfrom
ai-findings-autofix/src-include-handlers-management-user.py
Jun 6, 2026
Merged

Potential fixes for 5 code quality findings#63
Creeper19472 merged 6 commits into
masterfrom
ai-findings-autofix/src-include-handlers-management-user.py

Conversation

@Creeper19472

@Creeper19472 Creeper19472 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

This PR applies 5/5 suggestions from code quality AI findings.

Summary by Sourcery

Simplify user management handlers by removing redundant username validation and correcting an authentication error message.

Bug Fixes:

  • Correct the authentication failure message text for invalid user or token responses.

Enhancements:

  • Remove duplicate username-required checks in user deletion and user info retrieval handlers, relying on upstream validation instead.

Creeper19472 and others added 5 commits June 6, 2026 20:05
…opilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…opilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…opilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…opilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…opilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
@sourcery-ai

sourcery-ai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes redundant username presence validations in user management handlers and corrects a typo in authentication error messages, simplifying request handling while preserving core permission and token checks.

Sequence diagram for updated user info retrieval handler flow

sequenceDiagram
    actor Client
    participant ConnectionHandler
    participant RequestGetUserInfoHandler
    participant Session
    participant User

    Client->>ConnectionHandler: send get_user_info request (username)
    ConnectionHandler->>RequestGetUserInfoHandler: handle(handler)
    RequestGetUserInfoHandler->>ConnectionHandler: read data[username]
    RequestGetUserInfoHandler->>Session: Session()
    activate Session
    RequestGetUserInfoHandler->>User: get_existing(session, handler.username)
    User-->>RequestGetUserInfoHandler: this_user or None
    alt [this_user is None or token invalid]
        RequestGetUserInfoHandler->>ConnectionHandler: conclude_request(401, {}, Invalid user or token)
    else [this_user valid]
        RequestGetUserInfoHandler-->>ConnectionHandler: return user info
    end
    deactivate Session
Loading

File-Level Changes

Change Details Files
Remove redundant username-required checks before user deletion and user info retrieval.
  • Drop explicit empty-username validation blocks that returned 400 with 'Username is required'.
  • Rely on existing request validation or database lookups to handle missing or invalid usernames without early handler exits.
src/include/handlers/management/user.py
Fix typo in user/token authentication error response message.
  • Update error message from 'Invaild user or token' to 'Invalid user or token' for token validation failures in unblock and another permission-checked handler.
  • Keep existing 401 behavior and response structure while correcting the user-facing string.
src/include/handlers/management/user.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Creeper19472 Creeper19472 marked this pull request as ready for review June 6, 2026 12:06

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Now that the explicit username presence checks are removed, ensure that handler.data is always validated upstream so these handlers can't see a missing or empty username (otherwise you'll get a KeyError or a less clear 404 response).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that the explicit `username` presence checks are removed, ensure that `handler.data` is always validated upstream so these handlers can't see a missing or empty `username` (otherwise you'll get a KeyError or a less clear 404 response).

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Creeper19472 Creeper19472 merged commit dc842f1 into master Jun 6, 2026
6 checks passed
@Creeper19472 Creeper19472 deleted the ai-findings-autofix/src-include-handlers-management-user.py branch June 6, 2026 12:13
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.

1 participant