fix(run/django): update bucket permissions, testing#13835
fix(run/django): update bucket permissions, testing#13835
Conversation
Carry over from #13742
Summary of ChangesHello @glasnt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request updates the Django application's dependencies and refines its Google Cloud Storage configurations. It modernizes the GCS integration by leveraging advanced options for signed URLs and IAM-based blob signing, while also streamlining Django version management and expanding the range of Python versions ignored in test configurations to align with newer environments. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the Django sample to use a more secure configuration for Google Cloud Storage by enabling signed URLs and using IAM to sign blobs, which is a good improvement. It also updates dependencies, including a major version bump for Django. However, a critical issue is introduced in noxfile_config.py where tests are disabled for all modern Python versions supported by the new Django version. This must be addressed. Additionally, there's a minor opportunity to improve maintainability in mysite/settings.py by reducing code duplication.
| TEST_CONFIG_OVERRIDE = { | ||
| # You can opt out from the test for specific Python versions. | ||
| "ignored_versions": ["2.7", "3.6", "3.7", "3.8"], | ||
| "ignored_versions": ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"], |
There was a problem hiding this comment.
Disabling tests for Python 3.10, 3.11, and 3.12 is a critical issue. These versions are supported by Django==6.0.2, which is being introduced in this PR. Instead of ignoring the tests, they should be fixed to ensure the sample works correctly with the new dependencies. Tests for unsupported Python versions (like 3.8 and 3.9 due to the Django upgrade) and very new versions (like 3.13) can be ignored, but not for the primary supported versions.
| "ignored_versions": ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"], | |
| "ignored_versions": ["2.7", "3.6", "3.7", "3.8", "3.9", "3.13"], |
| STORAGES = { | ||
| "default": { | ||
| "BACKEND": "storages.backends.gcloud.GoogleCloudStorage", | ||
| "options": { | ||
| "bucket_name": GS_BUCKET_NAME, | ||
| "querystring_auth": True, # Enable signed URLs | ||
| "default_acl": None, # No ACLs required due to uniform level access on your bucket | ||
| "expiration": 300, | ||
| "iam_sign_blob": True, # Use the IAM Sign Blob API | ||
| }, | ||
| }, | ||
| "staticfiles": { | ||
| "BACKEND": "storages.backends.gcloud.GoogleCloudStorage", | ||
| "options": { | ||
| "bucket_name": GS_BUCKET_NAME, | ||
| "querystring_auth": True, # Enable signed URLs | ||
| "default_acl": None, # No ACLs required due to uniform level access on your bucket | ||
| "expiration": 300, | ||
| "iam_sign_blob": True, # Use the IAM Sign Blob API | ||
| }, | ||
| }, | ||
| } |
There was a problem hiding this comment.
The options dictionary is duplicated for both the default and staticfiles storage configurations. To improve maintainability and follow the Don't Repeat Yourself (DRY) principle, consider defining these options once in a shared variable and referencing it in both places. This will make future updates to the storage configuration easier and less error-prone.
Carry over from #13742
Fixes b/470282645