@@ -395,26 +395,10 @@ export async function resolveParams(
395395
396396 const [ needSecret , needPrompt ] = partition ( outstanding , ( param ) => param . type === "secret" ) ;
397397
398- // Check for missing secrets in non-interactive mode
399- if ( nonInteractive && needSecret . length > 0 ) {
400- const secretNames = needSecret . map ( ( p ) => p . name ) . join ( ", " ) ;
401- const commands = needSecret
402- . map (
403- ( p ) =>
404- `\tfirebase functions:secrets:set ${ p . name } ${ ( p as SecretParam ) . format === "json" ? " --format=json --data-file <file.json>" : "" } ` ,
405- )
406- . join ( "\n" ) ;
407- throw new FirebaseError (
408- `In non-interactive mode but have no value for the following secrets: ${ secretNames } \n\n` +
409- "Set these secrets before deploying:\n" +
410- commands ,
411- ) ;
412- }
413-
414398 // The functions emulator will handle secrets
415399 if ( ! isEmulator ) {
416400 for ( const param of needSecret ) {
417- await handleSecret ( param as SecretParam , firebaseConfig . projectId ) ;
401+ await handleSecret ( param as SecretParam , firebaseConfig . projectId , nonInteractive ) ;
418402 }
419403 }
420404
@@ -481,9 +465,20 @@ function populateDefaultParams(config: FirebaseConfig): Record<string, ParamValu
481465 * to read its environment variables. They are instead provided through GCF's own
482466 * Secret Manager integration.
483467 */
484- async function handleSecret ( secretParam : SecretParam , projectId : string ) : Promise < void > {
468+ async function handleSecret (
469+ secretParam : SecretParam ,
470+ projectId : string ,
471+ nonInteractive ?: boolean ,
472+ ) : Promise < void > {
485473 const metadata = await secretManager . getSecretMetadata ( projectId , secretParam . name , "latest" ) ;
486474 if ( ! metadata . secret ) {
475+ if ( nonInteractive ) {
476+ throw new FirebaseError (
477+ `In non-interactive mode but have no value for the secret: ${ secretParam . name } \n\n` +
478+ "Set this secret before deploying:\n" +
479+ `\tfirebase functions:secrets:set ${ secretParam . name } ${ secretParam . format === "json" ? " --format=json --data-file <file.json>" : "" } ` ,
480+ ) ;
481+ }
487482 const promptMessage = `This secret will be stored in Cloud Secret Manager (https://cloud.google.com/secret-manager/pricing) as ${
488483 secretParam . name
489484 } . Enter ${ secretParam . format === "json" ? "a JSON value" : "a value" } for ${
0 commit comments