Skip to content

Conversation

@avirajsingh7
Copy link
Collaborator

@avirajsingh7 avirajsingh7 commented Aug 27, 2025

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Please add here if any other information is required for the reviewer.

Summary by CodeRabbit

  • New Features
    • Onboarding now accepts organization names with a single character (previous minimum was three). This enables users with short names, initials, or abbreviations to complete signup more easily, reducing friction in the flow. Forms validate and submit as expected with these shorter names, and the overall onboarding experience remains unchanged aside from this increased flexibility.

@coderabbitai
Copy link

coderabbitai bot commented Aug 27, 2025

Walkthrough

Relaxed minimum length validation for OnboardingRequest.organization_name in backend/app/models/onboarding.py from 3 to 1. No other logic or control flow changes.

Changes

Cohort / File(s) Change Summary
Onboarding model validation
backend/app/models/onboarding.py
Updated OnboardingRequest.organization_name field: min_length changed from 3 to 1

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested labels

ready-for-review

Suggested reviewers

  • nishika26
  • AkhileshNegi
  • kartpop

Poem

A hop and a skip through fields of code,
I nibbled a rule, made lighter the load.
One little letter can now make a name,
Thump-thump! Validation plays a gentler game.
Ears up high, I approve this tweak—
Carrots for all, ship it this week! 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/org_name

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@codecov
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@avirajsingh7 avirajsingh7 merged commit 5579c37 into main Aug 27, 2025
2 of 3 checks passed
@avirajsingh7 avirajsingh7 deleted the hotfix/org_name branch August 27, 2025 16:27
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
backend/app/models/onboarding.py (3)

69-81: Normalize names pre-validation (trim/collapse spaces).

To avoid "\tA B " variants and accidental empties after trim, add a pre-validation normalizer.

You can add this validator (outside the shown lines) above set_defaults:

@model_validator(mode="before")
@classmethod
def _normalize(cls, data):
    if isinstance(data, dict):
        for key in ("organization_name", "project_name"):
            v = data.get(key)
            if isinstance(v, str):
                # trim and collapse internal whitespace
                v = re.sub(r"\s+", " ", v.strip())
                data[key] = v
    return data

And keep the pattern=r".*\S.*" guard to reject all-whitespace after trimming.


25-29: Add targeted tests for the relaxed constraint.

Cover edge cases: 1-char ok, whitespace-only rejected (with the new pattern), long names near limit.

Example pytest cases (API route):

def test_onboard_org_name_single_char(client, superuser_token_headers):
    r = client.post("/api/v1/onboard", json={"organization_name": "A", "project_name": "P"}, headers=superuser_token_headers)
    assert r.status_code == 201

def test_onboard_org_name_whitespace_rejected(client, superuser_token_headers):
    r = client.post("/api/v1/onboard", json={"organization_name": " ", "project_name": "P"}, headers=superuser_token_headers)
    assert r.status_code == 422

Want me to add these in backend/app/tests/api/routes/test_onboarding.py?


25-29: Align onboarding.organization_name max_length with other models

The organization_name field in backend/app/models/onboarding.py is currently capped at max_length=100, while all core models use max_length=255 for organization and project names. To maintain consistency and avoid surprising validation errors during onboarding, update this limit to 255.

• File: backend/app/models/onboarding.py
Change:

   organization_name: str = Field(
       description="Name of the organization to be created or linked",
-        min_length=1,
-        max_length=100,
+        min_length=1,
+        max_length=255,
   )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 048e26e and 7ccf2d8.

📒 Files selected for processing (1)
  • backend/app/models/onboarding.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
backend/app/models/onboarding.py (3)
backend/app/models/organization.py (1)
  • OrganizationUpdate (29-31)
backend/app/tests/crud/test_onboarding.py (1)
  • test_onboard_project_new_organization_project_user (26-90)
backend/app/tests/api/routes/test_onboarding.py (1)
  • test_onboard_project_with_auto_generated_defaults (131-160)
⏰ 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). (1)
  • GitHub Check: checks (3.11.7, 6)
🔇 Additional comments (1)
backend/app/models/onboarding.py (1)

25-29: Change aligns with PR objective; OK to ship.

Lowering organization_name min length to 1 matches the requirement and is safe from a model perspective.

Comment on lines 25 to 29
organization_name: str = Field(
description="Name of the organization to be created or linked",
min_length=3,
min_length=1,
max_length=100,
)
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Block whitespace-only org names.

With min_length=1, inputs like " " will pass validation. Add a regex constraint to require at least one non-whitespace character.

Apply this minimal diff:

     organization_name: str = Field(
         description="Name of the organization to be created or linked",
-        min_length=1,
+        min_length=1,
+        pattern=r".*\S.*",
         max_length=100,
     )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
organization_name: str = Field(
description="Name of the organization to be created or linked",
min_length=3,
min_length=1,
max_length=100,
)
organization_name: str = Field(
description="Name of the organization to be created or linked",
min_length=1,
pattern=r".*\S.*",
max_length=100,
)
🤖 Prompt for AI Agents
In backend/app/models/onboarding.py around lines 25 to 29, the organization_name
Field allows whitespace-only strings because min_length=1 accepts " " — add a
regex constraint such as regex=r".*\S.*" to require at least one non-whitespace
character (i.e. change the Field call to include regex=r".*\S.*" while keeping
min_length and max_length).

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