Skip to content

Dev#110

Merged
ngovinh2k2 merged 4 commits intomainfrom
dev
Apr 17, 2026
Merged

Dev#110
ngovinh2k2 merged 4 commits intomainfrom
dev

Conversation

@ngovinh2k2
Copy link
Copy Markdown
Member

What?

Why?

How?

Testing?

  • Functional Testing
  • Security
  • Performance
  • Error Handling
  • Code Quality
  • Documentation
  • Database
  • Deployment
  • Final Review

Anything Else?

@ngovinh2k2 ngovinh2k2 merged commit 2519ce1 into main Apr 17, 2026
1 check passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the to_representation methods in the authentication and space serializers to rename keys for presigned URLs (e.g., avatar to url_avatar) and removes hardcoded .png extensions from S3 paths. It also adds a new presigned URL for build artifacts. The review feedback identifies that renaming these keys is a breaking change for the API and that removing the file extension might lead to invalid paths if the underlying data does not include it. Additionally, the reviewer noted that the new S3 calls in the space serializer lack the error handling found in the authentication serializer.

Comment on lines +146 to 149
data["url_avatar"] = get_presigned_url(
settings.AWS_S3.get("AWS_STORAGE_BUCKET_NAME"),
f"uploads/{instance.avatar}.png",
f"uploads/{instance.avatar}",
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This change introduces two potential issues: 1. Breaking Change: Renaming the key from avatar to url_avatar is a breaking change for the API. Since avatar remains in Meta.fields, the data dictionary will now contain the raw model value (filename) under the avatar key, while the presigned URL is moved to url_avatar. 2. Path Logic: Removing the .png extension assumes that the instance.avatar field now stores the full filename including the extension. If the database still only stores the identifier without the extension, the generated S3 path will be invalid.

Comment thread apps/space/serializers.py
Comment on lines +36 to 44
data["url_logo"] = get_presigned_url(
settings.AWS_S3.get("AWS_STORAGE_BUCKET_NAME"),
f"uploads/{instance.logo}.png",
f"uploads/{instance.logo}",
)
if instance.build_artifact:
data["url_build_artifact"] = get_presigned_url(
settings.AWS_S3.get("AWS_STORAGE_BUCKET_NAME"),
f"uploads/{instance.build_artifact}",
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There are two main concerns with this implementation: 1. Inconsistent Error Handling: Unlike ProfileSerializer.to_representation, these calls to get_presigned_url are not wrapped in a try...except block. Failures in the external S3 service will cause the entire request to fail. 2. Breaking Change: Renaming the logo key to url_logo is a breaking change. The logo key will now return the raw value from the model instead of the presigned URL, which may break existing frontend integrations.

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