Skip to content

feat: accept Expression for v2 RTDB instance option#1869

Merged
IzaakGough merged 13 commits into
masterfrom
@invertase/fix-rtdb-instance-params
Jul 2, 2026
Merged

feat: accept Expression for v2 RTDB instance option#1869
IzaakGough merged 13 commits into
masterfrom
@invertase/fix-rtdb-instance-params

Conversation

@IzaakGough

@IzaakGough IzaakGough commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #1613

Summary

Allow the v2 Realtime Database trigger instance option to accept a deploy-time param (Expression<string>), not just a plain string.
This lets functions target different RTDB instances per environment without triggering the deployment-time .value() warning.

Problem

ReferenceOptions.instance was typed and handled as a plain string.

Passing defineString('REALTIME_INSTANCE') for instance either failed type-checking or caused the SDK to eagerly resolve the param during deploy, which emitted the standard .value() deployment warning.

Solution

  • Widen ReferenceOptions.instance to string | Expression<string>.
  • Preserve expression-backed instances through endpoint generation instead of resolving them in getOpts().
  • Serialize expression-backed instances into the manifest as CEL expressions.
  • Resolve the expression only at runtime when the trigger needs to construct its path pattern and event params.

Testing

  • Added unit coverage for getOpts() preserving an Expression<string>.
  • Added endpoint/manifest coverage for expression-backed instance values.
  • Added a test that verifies no deployment-time warning is emitted when defining the trigger with a param-backed instance.
  • Added a runtime test confirming instance resolution and param extraction still work.

@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 enhances Realtime Database (RTDB) ReferenceOptions to allow Expression<string> for the instance property, enabling dynamic resolution of instance names. The getOpts utility function has been updated to process these expressions, and a new test case validates this functionality. The review suggests improving the new test case by replacing magic strings with named constants for better readability and maintainability.

Comment thread spec/v2/providers/database.spec.ts Outdated
@IzaakGough IzaakGough marked this pull request as ready for review April 17, 2026 08:29
@IzaakGough IzaakGough requested a review from cabljac April 17, 2026 08:30
Comment thread src/v2/providers/database.ts Outdated

@CorieW CorieW left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@IzaakGough IzaakGough added this pull request to the merge queue Jun 25, 2026
@IzaakGough IzaakGough removed this pull request from the merge queue due to a manual request Jun 25, 2026
Comment thread src/v2/providers/database.ts Outdated
Comment thread src/v2/providers/database.ts Outdated
@IzaakGough IzaakGough requested a review from cabljac June 27, 2026 07:43
@IzaakGough IzaakGough enabled auto-merge June 29, 2026 12:25
@IzaakGough IzaakGough dismissed cabljac’s stale review July 2, 2026 13:18

These cleanups have been made now

auto-merge was automatically disabled July 2, 2026 13:20

Merge commits are not allowed on this repository

@IzaakGough IzaakGough merged commit 0ec6a1d into master Jul 2, 2026
31 checks passed
@IzaakGough IzaakGough deleted the @invertase/fix-rtdb-instance-params branch July 2, 2026 13:26
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.

Realtime instance can not be configured using params for onValueWritten functions

4 participants