Skip to content

fix: resolve secret name from defineSecret argument instead of variable name#180

Merged
demolaf merged 4 commits into
mainfrom
fix/secret-name-resolution
Jun 19, 2026
Merged

fix: resolve secret name from defineSecret argument instead of variable name#180
demolaf merged 4 commits into
mainfrom
fix/secret-name-resolution

Conversation

@demolaf

@demolaf demolaf commented May 12, 2026

Copy link
Copy Markdown
Member

When a secret is declared with defineSecret('TEST_SECRET') and passed to a function's secrets option, the spec builder was using the Dart variable name (e.g. testSecret) instead of the actual secret name passed to defineSecret (e.g. TEST_SECRET). This caused the Firebase CLI to look up the wrong secret in Secret Manager, resulting in a 404.

Fix

_extractSecretName in spec.dart now looks up the variable name in variableToParamName, which already contains the correct mapping built during AST traversal.

@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 support for secrets in Cloud Functions for Firebase by adding a secret definition and a usage example in an HTTPS function. It also updates the EndpointSpec to resolve secret names using a mapping. The review feedback points out that the secret name extraction logic should be expanded to handle prefixed identifiers and property access to prevent potential failures when secrets are referenced from other scopes.

Comment thread lib/src/builder/spec.dart Outdated
@demolaf demolaf marked this pull request as draft May 12, 2026 12:29
@demolaf demolaf marked this pull request as draft May 12, 2026 12:29
@demolaf demolaf marked this pull request as ready for review May 12, 2026 13:00
@demolaf demolaf requested review from Ehesp and kevmoo May 12, 2026 13:00
Comment thread test/snapshots/manifest_snapshot_test.dart
Comment thread test/snapshots/manifest_snapshot_test.dart Outdated
@demolaf demolaf force-pushed the fix/secret-name-resolution branch 2 times, most recently from 8966306 to 34fa873 Compare May 18, 2026 12:27
@demolaf demolaf requested a review from kevmoo May 18, 2026 12:28
…le name

# Conflicts:
#	test/snapshots/manifest_snapshot_test.dart
@demolaf demolaf force-pushed the fix/secret-name-resolution branch from 34fa873 to f71a76f Compare June 18, 2026 15:59
@kevmoo

kevmoo commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

/gemini review

@kevmoo

kevmoo commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Let's see what the agent has to say, too. But otherwise, LGTM!

@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 support for secret parameters (defineSecret and defineJsonSecret) across Dart and Node.js Firebase Functions, updating the endpoint specification builder to extract secret names and adding corresponding tests and examples. The review feedback highlights three key issues: a bug in the toUpperSnakeCase helper that incorrectly formats camelCase variable names (e.g., converting apiKey to APIKEY instead of API_KEY), a static analysis/compilation error in the snapshot tests due to unsafe access of nullable parameters, and a potential runtime RangeError in the example server when previewing short API keys.

Comment thread lib/src/builder/spec.dart
Comment thread test/snapshots/manifest_snapshot_test.dart
Comment thread example/https/bin/server.dart Outdated
@demolaf demolaf merged commit 3b1debb into main Jun 19, 2026
18 checks passed
@demolaf demolaf deleted the fix/secret-name-resolution branch June 19, 2026 10: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