firebase-functions icon indicating copy to clipboard operation
firebase-functions copied to clipboard

JsonSecretParam not accepted in secrets option (TypeScript typing mismatch with defineJsonSecret)

Open tzappia opened this issue 1 month ago • 2 comments

Related issues

None found for this typing gap with defineJsonSecret and secrets arrays.

[REQUIRED] Version info

node: node --version (v24.11.1)

firebase-functions: from package.json (7.0.0)

firebase-tools: firebase --version (14.26.0)

firebase-admin: from package.json (13.6.0)

[REQUIRED] Test case

import { defineJsonSecret, onRequest } from 'firebase-functions/https';

interface Config {
  foo: string;
}

const jsonSecret = defineJsonSecret<Config>('JSON_SECRET');

export const test = onRequest(
  { secrets: [jsonSecret] }, // TS error here
  (_req, res) => {
    res.json({ foo: jsonSecret.value().foo });
  }
);

[REQUIRED] Steps to reproduce

  1. Install firebase-functions v7.0.0.
  2. Define a JSON secret with defineJsonSecret.
  3. Pass the resulting JsonSecretParam into the secrets array of a function.
  4. Compile with TypeScript.

[REQUIRED] Expected behavior

TypeScript accepts JsonSecretParam in secrets (just like SecretParam or a string name), since JSON secrets are supported at runtime.

[REQUIRED] Actual behavior

TypeScript error:

Type 'JsonSecretParam<Config>' is not assignable to type 'string | SecretParam'.
  Type 'JsonSecretParam<Config>' is not assignable to type 'SecretParam'.
    The types returned by 'value()' are incompatible between these types.
      Type 'Config' is not assignable to type 'string'.

SDK typings show secrets?: (string | SecretParam)[]; across options. JsonSecretParam is defined in params/types, but not accepted by secrets. Runtime converters also only check instanceof SecretParam.

Were you able to successfully deploy your functions?

This is a compile time issue, I did not attempt to deploy.

tzappia avatar Dec 05 '25 16:12 tzappia

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Dec 05 '25 16:12 google-oss-bot

Hi @tzappia . Thanks for creating this issue! We've received it and will review it as soon as possible.

CorieW avatar Dec 05 '25 20:12 CorieW