Short answer
Add the secret to the function’s secrets option, read it with .value() inside the handler, and redeploy. Set or change it with firebase functions:secrets:set, then redeploy every function that uses it. For the emulator, put test values in a .secret.local file.
Rather not fix it yourself? App Fix Ticket starts with a fixed-price diagnosis, then a fixed price for the fix before any fix work.
Why the secret is missing, and the fix
01
The function doesn’t bind the secret
“Only functions that specifically include a secret in their secrets option will have access to that secret as an environment variable.” Firebase, Configure your environment (secrets)
Defining a secret isn’t enough. Each function that reads it has to list it in its secrets option.
const { onRequest } = require('firebase-functions/v2/https'); const { defineSecret } = require('firebase-functions/params'); const apiKey = defineSecret('PAYMENTS_API_KEY'); exports.checkout = onRequest({ secrets: [apiKey] }, async (req, res) => { const key = apiKey.value(); res.json({ ok: Boolean(key) }); });02
The value is read at the top of the file
“This means that fetching parameter values during global scope results in deployment failure.” Firebase, Configure your environment (parameters)
Calling .value() in global scope breaks the deploy. Read it inside the handler or in onInit. onInit runs for every function in the file, so check the value isn’t empty where the secret isn’t bound.
03
The secret changed but functions didn’t
“Whenever you set a new value for a secret, you must redeploy all functions that reference that secret for them to pick up the latest value.” Firebase, Configure your environment (managing secrets)
Running functions keep the value they were deployed with. Redeploy every function that uses the secret after you set a new value.
04
The secret was deleted
“Functions that use a secret value that has been deleted will fail silently.” Firebase, Configure your environment (managing secrets)
Check it still exists with firebase functions:secrets:get, and set it again if not.
Checked against the vendor’s docs on : Firebase docs: Configure your environment.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
Related: Firebase Functions deploy failed · Firebase callable INTERNAL error · Firebase Functions timeout · Firestore unsupported field value: undefined