Skip to content

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

@tzappia

Description

@tzappia

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions