Skip to content

Functions can now declare dependencies on additional APIs#1900

Merged
inlined merged 5 commits into
masterfrom
add-requires-api-feature
Jun 12, 2026
Merged

Functions can now declare dependencies on additional APIs#1900
inlined merged 5 commits into
masterfrom
add-requires-api-feature

Conversation

@inlined

@inlined inlined commented Jun 10, 2026

Copy link
Copy Markdown
Member

Description

Adds a new user-facing requiresAPI function to declare Google Cloud API dependencies in code. These are appended to the wire protocol manifest.

Scenarios Tested

  • Unit tests verify that requiresAPI correctly populates the requiredAPIs field in the generated manifest.

### Description
Adds a new user-facing `requiresAPI` function to declare Google Cloud API dependencies in code. These are appended to the wire protocol manifest.

### Scenarios Tested
- Unit tests verify that `requiresAPI` correctly populates the `requiredAPIs` field in the generated manifest.
@inlined inlined requested a review from wandamora June 10, 2026 20:29

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 introduces the requiresAPI function to both v1 and v2 SDKs, allowing developers to declare Google Cloud API dependencies directly in their code. These dependencies are collected globally and appended to the manifest during stack loading. The review feedback highlights a critical issue where the global globalRequiredAPIs array is not cleared after stack loading, which can lead to state accumulation and duplicate entries in long-running processes like the Firebase Emulator. Additionally, it is recommended to add input validation to the requiresAPI function to ensure that the API name is a valid, non-empty string.

Comment thread src/runtime/loader.ts Outdated
Comment thread src/runtime/loader.ts
Comment thread src/common/api.ts Outdated
- Enforced `${string}.googleapis.com` template literal type and runtime validation for `requiresAPI`.
- Cleared global API state after `loadStack` to prevent memory leaks in long running watch processes.
- Added unit tests covering the new validation logic.
inlined added 3 commits June 11, 2026 20:36
Fixes CI unit test failures where global parameter state from previous unit tests leaked into subsequent test expectations.
Fixes edge-case CI test failures where Node.js `require.cache` prevented fixture modules from re-executing and re-populating global parameter and API states when loaded a second time via absolute paths.
@inlined inlined enabled auto-merge June 12, 2026 20:26
@inlined inlined added this pull request to the merge queue Jun 12, 2026
Merged via the queue into master with commit d2321f7 Jun 12, 2026
36 checks passed
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.

3 participants