Skip to content

Conversation

@taeold
Copy link
Contributor

@taeold taeold commented Nov 13, 2025

This PR makes runtime and buildConfig optional for cloud functions.

This prevents the TypeError: Cannot read properties of undefined (reading 'runtime') crash that occurred during parallel deployments when the API returned a function object without buildConfig - which could happen during early part of function creation.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @taeold, 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 enhances the robustness of function deployments by making runtime and buildConfig properties optional in internal data structures. This change specifically targets and resolves a TypeError that could occur during parallel deployments when the API provided incomplete function objects. By adjusting type definitions and implementing safer access patterns, the system can now gracefully handle missing configuration details without crashing, while still enforcing necessary requirements for function creation and updates.

Highlights

  • Preventing Crash on Parallel Deploys: This PR addresses a TypeError that occurred during parallel deployments when the API returned a function object without buildConfig, by making runtime and buildConfig optional in internal type representations.
  • Type Definition Updates: The CloudFunctionBase interface now has an optional buildConfig, and the Endpoint type has an optional runtime. Conversely, InputCloudFunction explicitly requires buildConfig for creation/updates.
  • Safe Access Patterns: Code has been updated to safely access buildConfig and runtime using optional chaining (?.) and nullish coalescing (||), preventing crashes when these properties might be undefined.
  • Runtime Handling and Validation: Logging for function operations now gracefully handles undefined runtime values, and V1 function deployment logic has been updated to explicitly throw an error if runtime is missing.
  • Regression Test Added: A new regression test has been added to src/gcp/cloudfunctionsv2.spec.ts to ensure that functions without buildConfig are correctly converted without issues.
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 effectively addresses a crash that occurs during parallel deployments by making runtime and buildConfig optional in the internal Endpoint representation and CloudFunction types. The changes are well-implemented, using safe access patterns like optional chaining and conditional checks to handle potentially undefined properties. The addition of a regression test for functions without a buildConfig is a great way to ensure this fix is robust. The codebase is now more resilient to incomplete API responses. The changes are correct and I have no further suggestions.

@taeold taeold enabled auto-merge (squash) November 13, 2025 15:27
Copy link
Contributor

@jhuleatt jhuleatt left a comment

Choose a reason for hiding this comment

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

giving this one a rubber stamp - are there risks to making these optional?

@taeold taeold merged commit 363d3f8 into master Nov 13, 2025
50 checks passed
@taeold taeold deleted the fix-optional-runtime branch November 13, 2025 16:11
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions Nov 13, 2025
@taeold
Copy link
Contributor Author

taeold commented Nov 13, 2025

@jhuleatt spent some time to make sure it doesn't impact deploys. smoke deploy worked fine. it is a bit scary change, so I'll monitor GitHub issues after release.

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