-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: endpoint to get all files #21
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Pratiksha Sankhe <[email protected]>
Reviewer's Guide by SourceryThis pull request implements a new endpoint to retrieve a list of all files in the MinIO storage. The changes include updating the API specification and adding a new controller function to handle the endpoint. File-Level Changes
Tips
|
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.
Hey @psankhe28 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider implementing pagination for the file list to handle large numbers of files more efficiently.
- The error handling could be more granular. Instead of catching all S3Errors and returning a 500 status code, consider handling different types of S3Errors separately and returning appropriate status codes.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
|
||
def list_files(): | ||
"""Endpoint to list all files in the MinIO bucket.""" | ||
try: |
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.
suggestion: Implement more granular error handling.
Consider catching more specific exceptions in addition to S3Error. This could help in providing more accurate error messages to the client.
try:
minio_client = get_minio_client()
objects = minio_client.list_objects("files")
except minio.error.S3Error as s3_err:
raise HTTPException(status_code=500, detail=f"S3 error: {str(s3_err)}")
except minio.error.MinioException as minio_err:
raise HTTPException(status_code=500, detail=f"MinIO error: {str(minio_err)}")
except Exception as e:
raise HTTPException(status_code=500, detail=f"Unexpected error: {str(e)}")
"""Endpoint to list all files in the MinIO bucket.""" | ||
try: | ||
minio_client = get_minio_client() | ||
objects = minio_client.list_objects("files") |
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.
suggestion: Avoid hardcoding the bucket name.
Instead of hardcoding "files" as the bucket name, consider making it a configurable parameter. This will make the code more flexible and easier to maintain.
MINIO_BUCKET_NAME = os.getenv('MINIO_BUCKET_NAME', 'files')
objects = minio_client.list_objects(MINIO_BUCKET_NAME)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #21 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 23 23
=========================================
Hits 23 23
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Description
Checklist
of this project, including, in particular, with regard to any style guidelines
Conventional Commits specification; in particular, it clearly
indicates that a change is a breaking change
using the PR title as the commit message
changed behavior
or updated existing ones (only for Python, TypeScript, etc.)
(Google-style Python docstrings) for all
packages/modules/functions/classes/methods or updated existing ones
works
Comments
Summary by Sourcery
Add a new API endpoint to list all files in the MinIO storage, including the implementation of a corresponding controller function to handle the requests and return the file list.
New Features:
Enhancements: