Skip to content

Fix username validation regex#56

Open
numbpill3d wants to merge 1 commit intomainfrom
codex/update-username-validation-regex
Open

Fix username validation regex#56
numbpill3d wants to merge 1 commit intomainfrom
codex/update-username-validation-regex

Conversation

@numbpill3d
Copy link
Copy Markdown
Collaborator

@numbpill3d numbpill3d commented Jun 8, 2025

Summary

  • ensure username regex uses full match with Unicode flag
  • add stub server/models/Item.js required by tests

Testing

  • SUPABASE_URL=http://localhost SUPABASE_KEY=anon SUPABASE_SERVICE_KEY=service npm test (fails: Supabase connection errors)

https://chatgpt.com/codex/tasks/task_e_68450e32178c832f959989853ac95086

Summary by Sourcery

Fix username validation to enforce allowed characters with Unicode support and provide a stub Item model for tests

Bug Fixes:

  • Correct username validation regex to use full-match with Unicode flag

Chores:

  • Add stub server/models/Item.js to satisfy test dependencies

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Jun 8, 2025

Reviewer's Guide

This PR strengthens username validation by enforcing a full-match regex with Unicode support and introduces a stub Item model required by tests.

Sequence diagram for username validation in user registration

sequenceDiagram
    actor User
    participant Server_RegisterRoute as "POST /register"
    participant ValidationLogic as "Username Validation"

    User->>Server_RegisterRoute: Submit registration form (username, ...)
    Server_RegisterRoute->>ValidationLogic: Validate username
    activate ValidationLogic
    ValidationLogic-->>Server_RegisterRoute: Validation result (success/failure)
    deactivate ValidationLogic
    alt Validation successful
        Server_RegisterRoute->>User: Registration successful
    else Validation failed
        Server_RegisterRoute->>User: Error: "Username can only contain letters, numbers, underscores, and hyphens"
    end
Loading

Class diagram for the new Item model

classDiagram
    class Item {
        +findRecent(): Promise<Array>
        +findFeatured(): Promise<Array>
    }
Loading

File-Level Changes

Change Details Files
Enhanced username validation to use full match with Unicode support
  • Added Unicode ('u') flag to regex
  • Inserted comment clarifying full-match enforcement
server/routes/users.js
Added stub Item model to satisfy tests
  • Created server/models/Item.js
  • Defined async findRecent and findFeatured methods
server/models/Item.js

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

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @numbpill3d - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

Comment on lines +2 to +3
findRecent: async () => [],
findFeatured: async () => []
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.

The methods findRecent and findFeatured are defined as asynchronous but return static, empty arrays. This is not typical use of asynchronous functions, which are generally used for operations that involve I/O, like database interactions.

Recommendation: If these methods are intended to interact with a database in the future, consider implementing the actual database queries now, or if they should remain simple, remove the async keyword until it's necessary. This will avoid confusion and potential misuse of the methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant