-
Notifications
You must be signed in to change notification settings - Fork 24
fix: standardize timestamp fields to camelCase in API responses #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,29 @@ | ||
| from datetime import datetime | ||
| from typing import Optional | ||
|
|
||
| from pydantic import BaseModel, EmailStr | ||
| from pydantic import BaseModel, EmailStr, Field | ||
| from pydantic.config import ConfigDict | ||
|
|
||
|
|
||
| class UserProfileResponse(BaseModel): | ||
| id: str | ||
| name: str | ||
| email: EmailStr | ||
| imageUrl: Optional[str] = None | ||
| image_url: Optional[str] = Field(default=None, alias="imageUrl") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify service layer field naming consistency. The schema now uses 🏁 Script executed: #!/bin/bash
# Description: Check for field naming consistency between schemas and service layer
# Expected: Service layer should use snake_case field names or be updated accordingly
# Check user service for field usage
rg -A 3 -B 3 "imageUrl|image_url" backend/app/user/service.py
# Check for any remaining camelCase usage in service files that should be snake_case
rg -A 2 -B 2 "imageUrl.*=" backend/app/user/Length of output: 829 Service layer should use snake_case internal field names The service layer currently accesses and filters updates using • Change retrieval from Example diff: @@ backend/app/user/service.py
- "imageUrl": user.get("imageUrl") or user.get("avatar"),
+ "imageUrl": user.get("image_url") or user.get("avatar"),
- allowed = {"name", "imageUrl", "currency"}
+ allowed = {"name", "image_url", "currency"}With 🤖 Prompt for AI Agents |
||
| currency: str = "USD" | ||
| createdAt: datetime | ||
| updatedAt: datetime | ||
| created_at: datetime = Field(alias="createdAt") | ||
| updated_at: datetime = Field(alias="updatedAt") | ||
|
|
||
| model_config = ConfigDict(populate_by_name=True) | ||
|
|
||
|
|
||
| class UserProfileUpdateRequest(BaseModel): | ||
| name: Optional[str] = None | ||
| imageUrl: Optional[str] = None | ||
| image_url: Optional[str] = Field(default=None, alias="imageUrl") | ||
| currency: Optional[str] = None | ||
|
|
||
| model_config = ConfigDict(populate_by_name=True) | ||
|
|
||
|
|
||
| class DeleteUserResponse(BaseModel): | ||
| success: bool = True | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,7 +75,7 @@ async def test_signup_with_existing_email(mock_db): | |
| "email": existing_email, | ||
| "hashed_password": "hashedpassword", | ||
| "name": "Existing User", | ||
| "created_at": "sometime", # Simplified for mock | ||
| "createdAt": "sometime", # Simplified for mock | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify database field naming convention. The test data now uses Also applies to: 174-174, 217-217 🏁 Script executed: #!/bin/bash
# Description: Check if database operations use snake_case or camelCase field names
# Expected: Database operations should use snake_case, API responses use camelCase via aliases
# Check auth service for database field usage
rg -A 3 -B 3 "created_at|createdAt" backend/app/auth/service.py
# Check user service for database field usage
rg -A 3 -B 3 "created_at|createdAt" backend/app/user/service.py
# Check database schemas/models
rg -A 3 -B 3 "created_at|createdAt" backend/app/models/Length of output: 1603 Use snake_case for DB mocks; camelCase only in API responses The auth service and user service both write/read Please update
🤖 Prompt for AI Agents |
||
| } | ||
| ) | ||
|
|
||
|
|
@@ -171,7 +171,7 @@ async def test_login_with_email_success(mock_db): | |
| "avatar": None, | ||
| "currency": "USD", | ||
| # Ensure datetime is used | ||
| "created_at": datetime.now(timezone.utc), | ||
| "createdAt": datetime.now(timezone.utc), | ||
| "auth_provider": "email", | ||
| "firebase_uid": None, | ||
| } | ||
|
|
@@ -214,7 +214,7 @@ async def test_login_with_incorrect_password(mock_db): | |
| "email": user_email, | ||
| "hashed_password": get_password_hash(correct_password), | ||
| "name": "Wrong Pass User", | ||
| "created_at": datetime.now(timezone.utc), | ||
| "createdAt": datetime.now(timezone.utc), | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||
| from unittest.mock import AsyncMock, patch | ||||
|
|
||||
| import pytest | ||||
| from app.auth.dependencies import get_current_user | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused import. The -from app.auth.dependencies import get_current_user📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.12.2)4-4: Remove unused import: (F401) 🤖 Prompt for AI Agents |
||||
| from app.expenses.schemas import ExpenseCreateRequest, ExpenseSplit | ||||
| from fastapi import status | ||||
| from httpx import ASGITransport, AsyncClient | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical issues in function refactoring - function is broken
The refactoring from instance method to standalone function has introduced several critical issues:
self: Line 317 callsself.get_db()but the function is no longer an instance methodObjectIdis already imported at line 16, the import at line 307 is unnecessaryexcept Exceptionshould use proper exception chainingApply this diff to fix the issues:
📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.12.2)
307-307: Redefinition of unused
ObjectIdfrom line 16Remove definition:
ObjectId(F811)
322-324: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
🤖 Prompt for AI Agents