Skip to content

Standardize API endpoints by removing trailing slashes#577

Open
ankit-mehta07 wants to merge 2 commits intoProjectTech4DevAI:mainfrom
ankit-mehta07:remove-trailing-slashes
Open

Standardize API endpoints by removing trailing slashes#577
ankit-mehta07 wants to merge 2 commits intoProjectTech4DevAI:mainfrom
ankit-mehta07:remove-trailing-slashes

Conversation

@ankit-mehta07
Copy link

@ankit-mehta07 ankit-mehta07 commented Feb 3, 2026

Fixes #561

Summary

  • Removed trailing slashes from API endpoints
  • Updated tests to reflect the new endpoint format

Motivation

Standardizing endpoint URLs improves consistency and avoids ambiguity for API clients.

Summary by CodeRabbit

  • New Features

    • Added file size validation for document uploads with a 50MB maximum limit (configurable). Oversized files are rejected with error 413; empty files return error 422.
  • API Improvements

    • Removed trailing slashes from select endpoints for cleaner URL formatting.

@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

This change introduces document upload file size validation with a configurable 50MB limit (rejecting oversized files with HTTP 413 and empty files with HTTP 422), alongside standardizing API endpoint paths by removing trailing slashes from routes across login, private, documents, and utility endpoints.

Changes

Cohort / File(s) Summary
File Upload Validation Service
backend/app/services/documents/validators.py, backend/app/api/routes/documents.py, backend/app/core/config.py
New async validator module that checks file size and emptiness; integrated into upload route with pre-upload validation; MAX_DOCUMENT_UPLOAD_SIZE_MB config setting added (default 50MB).
API Endpoint Path Normalization
backend/app/api/routes/login.py, backend/app/api/routes/private.py, backend/app/api/routes/utils.py
Removed trailing slashes from /reset-password/, /users/, and /health/ endpoint paths for consistency.
Documentation & Tests
backend/app/api/docs/documents/upload.md, backend/app/tests/api/routes/documents/test_route_document_upload.py, backend/app/tests/api/routes/test_login.py, backend/app/tests/api/routes/test_private.py
Added file size restrictions documentation; added three new upload tests (size limit exceeded, empty file, within limit); updated route tests to match new endpoint paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Files now sized just right, oh what a sight!
No trailing slashes to cause a fright,
Validation hops in before the rest,
Fifty megs max—we've passed the test!
Clean endpoints shine, consistency's bright! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3
❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses issue #561's requirement to remove trailing slashes from endpoints, with changes to /users/, /reset-password/, and /health/ routes. However, it also includes unrelated file size validation changes not mentioned in #561. The PR mixes two unrelated features: trailing slash removal (#561) and file upload validation (separate feature). These should be split into separate PRs for clarity and focused review.
Out of Scope Changes check ⚠️ Warning The PR includes file size validation implementation (validators.py, config.py, upload.md, documents.py changes, and related tests) that is outside the scope of issue #561's trailing slash standardization objective. Extract the file size validation feature into a separate PR. Keep this PR focused solely on removing trailing slashes from API endpoints as defined in issue #561.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: standardizing API endpoints by removing trailing slashes, which matches the primary objective of issue #561.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

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/utils.py (1)

11-16: ⚠️ Potential issue | 🟡 Minor

Inconsistent: /test-email/ still has a trailing slash.

The PR objective is to remove trailing slashes from all API endpoints, but this endpoint still has one. For consistency, update the path to /test-email.

Proposed fix
 `@router.post`(
-    "/test-email/",
+    "/test-email",
     dependencies=[Depends(require_permission(Permission.SUPERUSER))],
     status_code=201,
     include_in_schema=False,
 )
🧹 Nitpick comments (2)
backend/app/services/documents/validators.py (2)

4-4: Remove unused import.

Path is imported but never used in this module.

Proposed fix
 import logging
-from pathlib import Path
 
 from fastapi import HTTPException, UploadFile

53-53: Log message should be prefixed with the function name.

As per coding guidelines, log messages should be prefixed with the function name in square brackets: logger.info(f"[function_name] Message").

Proposed fix
-    logger.info(f"Document file validated: {file.filename} ({file_size} bytes)")
+    logger.info(f"[validate_document_file] Document file validated: {file.filename} ({file_size} bytes)")

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.

Kaapi v1.0: Endpoint Consistency

1 participant