Skip to content
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

fix: OPTIC-1785: Validate S3 bucket name on storage connection form #7183

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mcanu
Copy link
Contributor

@mcanu mcanu commented Mar 7, 2025

This pull request introduces a mixin class to handle common functionality for S3 storage serializers and refactors existing serializers to use this mixin. The most important changes include the creation of the S3StorageSerializerMixin, the addition of a bucket name validation method, and the refactoring of S3ImportStorageSerializer and S3ExportStorageSerializer to use the new mixin.

Refactoring and code reuse:

  • Created S3StorageSerializerMixin to encapsulate common functionality for S3 storage serializers, including secure field handling and bucket name validation.
  • Refactored S3ImportStorageSerializer to inherit from S3StorageSerializerMixin and ImportStorageSerializer, consolidating common code and adding the presign field.
  • Refactored S3ExportStorageSerializer to inherit from S3StorageSerializerMixin and ExportStorageSerializer, consolidating common code.

Validation improvements:

  • Added validate_bucket method to S3StorageSerializerMixin to validate the bucket name using validate_bucket_name from botocore.handlers.

Code simplification:

  • Replaced references to S3ImportStorageSerializer.secure_fields with self.secure_fields to simplify code and improve maintainability.
Screen.Recording.2025-03-07.at.14.34.33.mov

@github-actions github-actions bot added the fix label Mar 7, 2025
Copy link

netlify bot commented Mar 7, 2025

Deploy Preview for label-studio-docs-new-theme canceled.

Name Link
🔨 Latest commit e3efe0c
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-docs-new-theme/deploys/67cb2dea3d580d00087ff213

Copy link

netlify bot commented Mar 7, 2025

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit e3efe0c
🔍 Latest deploy log https://app.netlify.com/sites/heartex-docs/deploys/67cb2dea6eab0e0008978f2f

Copy link

codecov bot commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 77.17%. Comparing base (4108f9e) to head (e3efe0c).
Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
label_studio/io_storages/s3/serializers.py 85.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7183      +/-   ##
===========================================
- Coverage    77.20%   77.17%   -0.04%     
===========================================
  Files          187      187              
  Lines        14484    14496      +12     
===========================================
+ Hits         11183    11187       +4     
- Misses        3301     3309       +8     
Flag Coverage Δ
pytests 77.17% <85.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcanu mcanu requested a review from wesleylima March 7, 2025 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant