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

Extension Emulator don’t load secretEnvs silently. #5062

Closed
kazuooooo opened this issue Oct 5, 2022 · 4 comments
Closed

Extension Emulator don’t load secretEnvs silently. #5062

kazuooooo opened this issue Oct 5, 2022 · 4 comments
Assignees

Comments

@kazuooooo
Copy link
Contributor

[REQUIRED] Environment info

firebase-tools: v11.13.0

Platform: macOS

[REQUIRED] Test case

  1. install stripe firebase extension
  2. run extensions by emulator
  3. Call ext-firestore-stripe-payments-createPortalLink in browser
import { httpsCallable } from 'firebase/functions'

const functionRef = httpsCallable<{ returnUrl: string }, { url: string }>(
  functions,
  'ext-firestore-stripe-payments-createPortalLink'
)
const { data } = await functionRef({
  returnUrl: window.location.href
})
window.location.assign(data.url)

[REQUIRED] Steps to reproduce

The same above.

[REQUIRED] Expected behavior

Emulator load fromSTRIPE_API_KEY and STRIPE_WEBHOOK_SECRET from Secret Manager.

STRIPE_API_KEY=projects/${param:PROJECT_NUMBER}/secrets/firestore-stripe-payments-STRIPE_API_KEY/versions/latest
STRIPE_WEBHOOK_SECRET=projects/${param:PROJECT_NUMBER}/secrets/firestore-stripe-payments-STRIPE_WEBHOOK_SECRET-fd8d/versions/latest

[REQUIRED] Actual behavior

Stripe Raise this error, because No API key provided from Firebase Runtime.

>  {"severity":"INFO","message":"⚙️ Creating checkout session for doc [nNEzStB2wCK3QbX9FAg7]."}
>  {"severity":"INFO","message":"⚙️ Creating customer object for [0uwT7MhNb8pjHjJZ1DMPhW8z9Wct]."}
>  {"severity":"ERROR","message":"❗️[Error]: Failed to create customer for [0uwT7MhNb8pjHjJZ1DMPhW8z9Wct]: You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/."}
>  {"severity":"ERROR","message":"❗️[Error]: Checkout session creation failed for doc [nNEzStB2wCK3QbX9FAg7]: Cannot read properties of null (reading 'stripeId')"}

I noticed, resolveSecretEnvs function silently not load secretEnvs, because called from startRuntime without trigger variable.
(I succeed to load by creating secret.local file)

I think Emulator show warning at least.

@kazuooooo kazuooooo added the bug label Oct 5, 2022
@gthemiller
Copy link

Any updates on this? Same thing happening to me

@b0ot
Copy link

b0ot commented Nov 21, 2022

I'm having the same issue, would appreciate any updates.

@joehan
Copy link
Contributor

joehan commented Dec 6, 2022

Hey all, sorry for the slow reply on this, I initially misunderstood the issue and thought it was lower priority. I spent some time trying to repro this, and I've discovered that it only occurs when running the emulator with the --inspect-functions flag. I'm going try to submit a fix soon, but as a temporary workaround, you can omit the --inspect-functions flag

@joehan
Copy link
Contributor

joehan commented Dec 6, 2022

Alright, this appears to be affecting all functions, not just extensions functions, and is a duplicate of #4605. I'm going to close this issue - please track there, as I am actively working on a fix.

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

No branches or pull requests

4 participants