fix: resolve secret name from defineSecret argument instead of variable name#180
Conversation
There was a problem hiding this comment.
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.
8966306 to
34fa873
Compare
…le name # Conflicts: # test/snapshots/manifest_snapshot_test.dart
34fa873 to
f71a76f
Compare
|
/gemini review |
|
Let's see what the agent has to say, too. But otherwise, LGTM! |
There was a problem hiding this comment.
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.
When a secret is declared with
defineSecret('TEST_SECRET')and passed to a function'ssecretsoption, the spec builder was using the Dart variable name (e.g.testSecret) instead of the actual secret name passed todefineSecret(e.g.TEST_SECRET). This caused the Firebase CLI to look up the wrong secret in Secret Manager, resulting in a 404.Fix
_extractSecretNameinspec.dartnow looks up the variable name invariableToParamName, which already contains the correct mapping built during AST traversal.