Conversation
📝 WalkthroughWalkthroughIntroduces a StripTrailingSlashMiddleware to strip single trailing slashes from HTTP request paths, registers it in the app middleware stack, adjusts many route decorator path arguments (removing explicit ChangesTrailing Slash Normalization
sequenceDiagram
participant Client as Client (HTTP)
participant Middleware as StripTrailingSlashMiddleware
participant App as FastAPI App / Router
participant Handler as Route Handler
Client->>Middleware: HTTP GET /foo/ (or /foo)
Middleware->>Middleware: strip trailing slash if present (not for /)
Middleware->>App: forward modified scope (path=/foo)
App->>Handler: route to handler for /foo
Handler-->>App: response (200)
App-->>Client: HTTP response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/app/api/routes/user_project.py (1)
122-128:⚠️ Potential issue | 🟠 Major | ⚡ Quick winLogging
entry.emailwithoutmask_stringviolates the coding guidelines.Lines 123 and 127 log raw email addresses (PII) to the application logger. Per the coding guidelines, sensitive values must be wrapped with
mask_string.🛡️ Proposed fix
- logger.info( - f"[add_project_users] Invitation email sent | email: {entry.email}" - ) + logger.info( + f"[add_project_users] Invitation email sent | email: {mask_string(str(entry.email))}" + ) ... - except Exception as e: - logger.error( - f"[add_project_users] Failed to send invitation email | email: {entry.email}, error: {e}" - ) + except Exception as e: + logger.error( + f"[add_project_users] Failed to send invitation email | email: {mask_string(str(entry.email))}, error: {e}" + )As per coding guidelines: "Prefix all log messages with the function name in square brackets:
logger.info(f"[function_name] Message {mask_string(sensitive_value)}")"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/app/api/routes/user_project.py` around lines 122 - 128, The logs in add_project_users are printing raw PII (entry.email) in logger.info and logger.error; update both calls to wrap the email with the mask_string helper (e.g., logger.info(f"[add_project_users] Invitation email sent | email: {mask_string(entry.email)}") and similarly for logger.error) so all sensitive values follow the masking guideline and keep the function name prefix intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/app/core/middleware.py`:
- Around line 16-28: Add precise type annotations to both methods: annotate
StripTrailingSlashMiddleware.__init__ with the ASGI app type (e.g., app:
"ASGIApp") and return -> None, and annotate
StripTrailingSlashMiddleware.__call__ with ASGI scope, receive and send types
(e.g., scope: "Scope", receive: "Receive", send: "Send") and return -> None (it
is an async def so its signature should be async def __call__(...) -> None).
Also add the necessary imports for the ASGI/Starlette types (Scope, Receive,
Send, ASGIApp) or appropriate typing aliases at the top of the module so the
annotations resolve. Ensure you update both method signatures (function names
__init__ and __call__) accordingly without changing runtime behavior.
---
Outside diff comments:
In `@backend/app/api/routes/user_project.py`:
- Around line 122-128: The logs in add_project_users are printing raw PII
(entry.email) in logger.info and logger.error; update both calls to wrap the
email with the mask_string helper (e.g., logger.info(f"[add_project_users]
Invitation email sent | email: {mask_string(entry.email)}") and similarly for
logger.error) so all sensitive values follow the masking guideline and keep the
function name prefix intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 590deacc-c46e-4aea-96d7-162ff27a6e1d
📒 Files selected for processing (41)
backend/app/api/main.pybackend/app/api/routes/api_keys.pybackend/app/api/routes/assistants.pybackend/app/api/routes/collections.pybackend/app/api/routes/config/config.pybackend/app/api/routes/credentials.pybackend/app/api/routes/doc_transformation_job.pybackend/app/api/routes/documents.pybackend/app/api/routes/languages.pybackend/app/api/routes/login.pybackend/app/api/routes/model_config.pybackend/app/api/routes/model_evaluation.pybackend/app/api/routes/openai_conversation.pybackend/app/api/routes/organization.pybackend/app/api/routes/private.pybackend/app/api/routes/project.pybackend/app/api/routes/user_project.pybackend/app/api/routes/users.pybackend/app/api/routes/utils.pybackend/app/core/middleware.pybackend/app/main.pybackend/app/tests/api/routes/collections/test_collection_list.pybackend/app/tests/api/routes/configs/test_config.pybackend/app/tests/api/routes/configs/test_version.pybackend/app/tests/api/routes/test_api_key.pybackend/app/tests/api/routes/test_assistants.pybackend/app/tests/api/routes/test_creds.pybackend/app/tests/api/routes/test_doc_transformation_job.pybackend/app/tests/api/routes/test_evaluation.pybackend/app/tests/api/routes/test_languages.pybackend/app/tests/api/routes/test_login.pybackend/app/tests/api/routes/test_model_config.pybackend/app/tests/api/routes/test_model_evaluation.pybackend/app/tests/api/routes/test_org.pybackend/app/tests/api/routes/test_private.pybackend/app/tests/api/routes/test_project.pybackend/app/tests/api/routes/test_users.pybackend/app/tests/api/test_auth_failures.pybackend/app/tests/api/test_user_project.pybackend/app/tests/core/test_exception_handlers.pybackend/app/tests/core/test_trailing_slash_compat.py
| def __init__(self, app): | ||
| self.app = app | ||
|
|
||
| async def __call__(self, scope, receive, send): |
There was a problem hiding this comment.
do add type hints as suggested by code rabbit
There was a problem hiding this comment.
🧹 Nitpick comments (1)
backend/app/api/routes/config/__init__.py (1)
5-8: 💤 Low valueLGTM — routing chain is correct after the refactor.
Both sub-routers resolve to
{API_V1_STR}/configs/…as expected, and the design correctly avoids the FastAPI constraint that prohibits an empty-path child route when the parentAPIRoutercarries no prefix.One optional note: if either
config.routerorversion.routeralready declarestags=["Config Management"], the tag will be duplicated in the OpenAPI schema. Consider omittingtagsfrom the leaf routers or from this parent to avoid the redundancy.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/app/api/routes/config/__init__.py` around lines 5 - 8, The OpenAPI tag "Config Management" is being applied both on the parent APIRouter (router) and possibly on leaf routers (config.router or version.router), which can produce duplicate tags in the schema; remove the duplicate by ensuring the tag is declared only once — either remove tags=["Config Management"] from the parent APIRouter named router and keep it on config.router/version.router, or remove tags from the leaf routers and keep it only on router so that only a single "Config Management" tag appears in the OpenAPI output.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@backend/app/api/routes/config/__init__.py`:
- Around line 5-8: The OpenAPI tag "Config Management" is being applied both on
the parent APIRouter (router) and possibly on leaf routers (config.router or
version.router), which can produce duplicate tags in the schema; remove the
duplicate by ensuring the tag is declared only once — either remove
tags=["Config Management"] from the parent APIRouter named router and keep it on
config.router/version.router, or remove tags from the leaf routers and keep it
only on router so that only a single "Config Management" tag appears in the
OpenAPI output.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 84ff7a65-bce4-414f-96f4-32d0906140b6
📒 Files selected for processing (2)
backend/app/api/routes/config/__init__.pybackend/app/core/middleware.py
🚧 Files skipped from review as they are similar to previous changes (1)
- backend/app/core/middleware.py
Issue: #561
Summary
StripTrailingSlashMiddleware(pure-ASGI) that rewrites/foo/to/foobefore routing, so existing integrations sending the trailing-slash form keep working, no 307 redirect, no auth-header loss on redirect, no double round-trip. To be removed in a future release once integrators have migrated.Checklist
Before submitting a pull request, please ensure that you mark these task.
fastapi run --reload app/main.pyordocker compose upin the repository root and test.Summary by CodeRabbit
New Features
Bug Fixes
Tests