Skip to content

fix(run/django): update bucket permissions, testing#13835

Draft
glasnt wants to merge 4 commits intomainfrom
django-update
Draft

fix(run/django): update bucket permissions, testing#13835
glasnt wants to merge 4 commits intomainfrom
django-update

Conversation

@glasnt
Copy link
Contributor

@glasnt glasnt commented Feb 17, 2026

Carry over from #13742

Fixes b/470282645

@product-auto-label product-auto-label bot added api: run Issues related to the Cloud Run API. samples Issues that are directly related to samples. labels Feb 17, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Google Cloud Storage Configuration: Updated the STORAGES backend settings in mysite/settings.py to use an options dictionary, enabling signed URLs, setting default_acl to None for uniform access, and utilizing the IAM Sign Blob API. The GS_DEFAULT_ACL was also explicitly set to None.
  • Python Version Testing: Expanded the ignored_versions list in noxfile_config.py to include Python versions 3.9 through 3.13, indicating a potential shift in testing strategy or environment for the sample.
  • Dependency Updates: Upgraded Django to version 6.0.2 and psycopg2-binary to 2.9.11 in requirements.txt, consolidating Django version management by removing conditional version specifications.
Changelog
  • run/django/mysite/settings.py
    • Configured Google Cloud Storage STORAGES backend with an options dictionary to specify bucket_name, enable querystring_auth, set default_acl to None, define expiration, and enable iam_sign_blob.
    • Changed GS_DEFAULT_ACL from "publicRead" to None.
  • run/django/noxfile_config.py
    • Extended the ignored_versions list to include Python versions 3.9, 3.10, 3.11, 3.12, and 3.13.
  • run/django/requirements.txt
    • Updated Django to 6.0.2 and removed version-specific conditional dependencies.
    • Updated psycopg2-binary to 2.9.11.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@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 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"],
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

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.

Suggested change
"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"],

Comment on lines 174 to 195
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
},
},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: run Issues related to the Cloud Run API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant