Skip to content

[InProgress] DEV#54

Open
Saurabh254 wants to merge 2 commits intomainfrom
dev
Open

[InProgress] DEV#54
Saurabh254 wants to merge 2 commits intomainfrom
dev

Conversation

@Saurabh254
Copy link
Owner

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds functionality to retrieve users by UUID, removes an unused field from settings filters, and cleans up deprecated Pydantic configuration. The PR is marked as "InProgress" in the title, suggesting it's still under development.

Changes:

  • Added new service function and endpoint to retrieve users by UUID
  • Removed settings_type field from SettingsFilter model
  • Removed deprecated orm_mode Config from CommentResponse schema

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
server/pin_sphere/users/service.py Added get_user_by_user_id function to fetch users by UUID, added models import
server/pin_sphere/users/filters.py Removed unused settings_type field and Literal import from SettingsFilter
server/pin_sphere/users/endpoint.py Added GET endpoint for retrieving users by UUID with new imports
server/pin_sphere/comments/schemas.py Removed deprecated orm_mode configuration from CommentResponse
Comments suppressed due to low confidence (1)

server/pin_sphere/users/filters.py:72

  • The removal of the settings_type field may cause issues with the update_settings function in service.py:132, which explicitly excludes "settings_type" when calling model_dump. With settings_type removed from the model, this exclusion is now referencing a non-existent field. While this won't cause an immediate error, the exclusion is now unnecessary and should be removed from service.py to keep the code clean.
    general: Optional[GeneralSettingsFilter] = None
    notification: Optional[NotificationSettingsFilter] = None
    appearance: Optional[AppearanceSettingsFilter] = None
    privacy_and_security: Optional[PrivacySecuritySettingsFilter] = None

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

async def get_user_by_user_id(
user_id: UUID = Path(), db: AsyncSession = Depends(get_async_session)
):
return await service.get_user_by_user_id(user_id, db)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

This endpoint lacks error handling when the user is not found. The function can return None (as specified in the service function return type), but there's no check to raise a 404 HTTPException when the user doesn't exist. Other similar endpoints in this file (like delete_account on line 109, read_user on line 184) properly check for None and raise appropriate exceptions. This should follow the same pattern.

Suggested change
return await service.get_user_by_user_id(user_id, db)
user = await service.get_user_by_user_id(user_id, db)
if not user:
raise HTTPException(status_code=404, detail="User not found")
return user

Copilot uses AI. Check for mistakes.


@router.get(
"/{user_id}",
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

This endpoint path "/{user_id}" conflicts with the existing "/{username}" GET endpoint on line 178. FastAPI will route requests to the first matching pattern, which means this new endpoint will intercept all requests intended for the username endpoint. When a client requests "/users/john", FastAPI will try to parse "john" as a UUID for this endpoint instead of treating it as a username. Consider using a more specific path like "/by-id/{user_id}" or "/user-id/{user_id}" to avoid this ambiguity.

Suggested change
"/{user_id}",
"/by-id/{user_id}",

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +31
async def get_user_by_user_id(
user_id: uuid.UUID, db: AsyncSession
) -> models.User | None:
query = select(models.User).filter(models.User.id == str(user_id))
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

There's an inconsistency in the model reference. This function uses models.User while other functions in the same file (like get_user, get_user_by_email, get_user_by_username) use the directly imported User from core.models. Since User is already imported on line 11, consider using User directly instead of models.User for consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
async def get_user_by_user_id(
user_id: uuid.UUID, db: AsyncSession
) -> models.User | None:
query = select(models.User).filter(models.User.id == str(user_id))
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The User model's id field is defined as UUID type in the database (see core/database/base_model.py:34), but this query converts the UUID to a string for comparison. This conversion may not be necessary depending on the database driver's UUID handling. Other functions in this file (like get_user, get_user_by_email) don't perform string conversion when filtering. Consider checking if the database driver handles UUID comparisons directly, and if so, use models.User.id == user_id instead for consistency and potential performance improvement.

Suggested change
query = select(models.User).filter(models.User.id == str(user_id))
query = select(models.User).filter(models.User.id == user_id)

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +29
async def get_user_by_user_id(
user_id: uuid.UUID, db: AsyncSession
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The parameter order is inconsistent with other service functions in this file. Other functions follow the pattern of putting the database session (db) as the first parameter (see get_user, get_user_by_email, get_user_by_username). This function should use get_user_by_user_id(db: AsyncSession, user_id: uuid.UUID) for consistency with established conventions in this file.

Copilot uses AI. Check for mistakes.
Comment on lines +90 to +91
summary="Delete user account",
description="Delete a user account by username. Returns the deleted user information.",
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The summary and description are incorrect for this endpoint. The endpoint is a GET operation that retrieves a user by ID, not a DELETE operation. The summary should be something like "Get user by ID" and the description should indicate that it retrieves user information by their unique user ID.

Suggested change
summary="Delete user account",
description="Delete a user account by username. Returns the deleted user information.",
summary="Get user by ID",
description="Retrieve user information by their unique user ID.",

Copilot uses AI. Check for mistakes.
@gitguardian
Copy link

gitguardian bot commented Feb 5, 2026

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
26880863 Triggered PostgreSQL Credentials 77ce6a4 server/alembic.ini View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

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