Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CallableOptions doesn't accept BooleanParam which is accepted by HttpsOptions #1554

Open
eli1stark opened this issue Apr 24, 2024 · 2 comments

Comments

@eli1stark
Copy link

Related issues

[REQUIRED] Version Info

node: v20.7.0

firebase-functions: v4.5.0

firebase-admin: v11.11.1

[REQUIRED] Test case

Provided below.

[REQUIRED] Steps to reproduce

When env variable used as shown in Google Docs it doesn't compile with CallableOptions, however the same param is used without issues with HttpsOptions. CallableOptions extends HttpsOptions, so it should have the same behavior as HttpsOptions.

my_function.ts

import {defineBoolean} from "firebase-functions/params";
import {onCall} from "firebase-functions/v2/https";

const enforceAppCheck = defineBoolean("ENFORCE_APP_CHECK");

export const myFunction = onCall({
  enforceAppCheck: enforceAppCheck,
}, async (request) => {

});

.env

ENFORCE_APP_CHECK=false

[REQUIRED] Expected behavior

env variable should be assignable without compile errors.

[REQUIRED] Actual behavior

Type 'BooleanParam' is not assignable to type 'boolean | undefined'.ts(2322)
https.d.ts(111, 5): The expected type comes from property 'enforceAppCheck' which is declared here on type 'CallableOptions'

Were you able to successfully deploy your functions?

Function doesn't deploy due to compile issues.

FIX

To fix the issue we need to update the code below:

export interface CallableOptions extends HttpsOptions {
  enforceAppCheck?: boolean;
  consumeAppCheckToken?: boolean;
}

to this code:

export interface CallableOptions extends HttpsOptions {
  enforceAppCheck?: boolean | Expression<boolean>;
  consumeAppCheckToken?: boolean | Expression<boolean>;
}
@google-oss-bot
Copy link
Collaborator

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

@colerogers
Copy link
Contributor

Hey @eli1stark thanks for noticing a feature gap! I've added a feature-request tag to this issue and hopefully we can get to it soon. Otherwise, if you (or anyone in the community) would like to take a crack at adding it, we'd love to have community contributions.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants