Skip to content

fix: add common variables to all functions#1676

Merged
davidgamez merged 3 commits into
mainfrom
fix_revalidate_calls
May 1, 2026
Merged

fix: add common variables to all functions#1676
davidgamez merged 3 commits into
mainfrom
fix_revalidate_calls

Conversation

@davidgamez
Copy link
Copy Markdown
Member

@davidgamez davidgamez commented Apr 29, 2026

Summary:

PMTiles generation failed due to missing GCP_REGION and SERVICE_ACCOUNT_EMAIL environment variables, and an error was thrown inside a catch block. This PR ensures that ENVIRONMENT, PROJECT_ID, GCP_REGION, and SERVICE_ACCOUNT_EMAIL are present in all functions.

[AI Comment]:

This pull request primarily standardizes and expands the environment variables passed to Google Cloud Functions in Terraform, ensuring consistency and adding missing variables. It also introduces a new utility script to automate the initialization of a local development environment. Additionally, there is a minor improvement to error handling in a Python utility.

Infrastructure improvements (Terraform environment variables):

  • Standardized and expanded the set of environment variables (ENVIRONMENT, PROJECT_ID, GCP_REGION, SERVICE_ACCOUNT_EMAIL) across all Google Cloud Functions in both infra/batch/main.tf and infra/functions-python/main.tf, ensuring all functions have consistent access to deployment context. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

Developer tooling:

  • Added a new script scripts/init-local-folder.sh to automate local environment setup, including database rebuilds, model and API stub generation, and function setup. This script supports an optional flag to populate the database with production data.

Code quality and error handling:

  • Improved error handling in api/src/shared/common/gcp_utils.py by removing the unused response variable and its logging in the exception block of create_http_task_with_name.

Expected behavior:

The environment, project ID, service account, and region variables are present in all GCP functions. PMTiles works as expected

Testing tips:

[internal team]

  • Go to retool
  • Select dev environment
  • Select a GTFS feed
  • Verify that the latest dataset is present and not large
  • Go to actions and execute the pmtiles generation
  • Verify that the pmtiles was properly generated

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with ./scripts/api-tests.sh to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)

logging.info("Task already exists for %s, skipping.", task_name)
else:
logging.error("Error creating task: %s", e)
logging.error("response: %s", response)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In case of error, this log was throwing another error due to response variable not initialized

@davidgamez davidgamez changed the title fix: add environment, project id and region variables to all functions fix: add common variables to all functions Apr 30, 2026
@davidgamez davidgamez merged commit acf9e5d into main May 1, 2026
27 of 28 checks passed
@davidgamez davidgamez deleted the fix_revalidate_calls branch May 1, 2026 15:21
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.

2 participants