Skip to content

Commit d229ee6

Browse files
authored
Fix type mismatch for parametrized function region (#6205)
* fix type mismatch for region param
1 parent f840896 commit d229ee6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Fix type mismatch for parametrized function region. (#6205)
12
- Ignore `FIRESTORE_EMULATOR_HOST` environment variable on functions deploy. (#6442)
23
- Added support for enabling, disabling, and displaying Point In Time Recovery enablement state on Firestore databases (#6388)
34
- Added a `--verbosity` flag to `emulators:*` commands that limits what logs are printed (#2859)

src/deploy/functions/build.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { assertExhaustive, mapObject, nullsafeVisitor } from "../../functional";
77
import { UserEnvsOpts, writeUserEnvs } from "../../functions/env";
88
import { FirebaseConfig } from "./args";
99
import { Runtime } from "./runtimes";
10+
import { ExprParseError } from "./cel";
1011

1112
/* The union of a customer-controlled deployment and potentially deploy-time defined parameters */
1213
export interface Build {
@@ -434,8 +435,21 @@ export function toBackend(
434435
let regions: string[] = [];
435436
if (!bdEndpoint.region) {
436437
regions = [api.functionsDefaultRegion];
437-
} else {
438+
} else if (Array.isArray(bdEndpoint.region)) {
438439
regions = params.resolveList(bdEndpoint.region, paramValues);
440+
} else {
441+
// N.B. setting region via GlobalOptions only accepts a String param.
442+
// Therefore if we raise an exception by attempting to resolve a
443+
// List param, we try resolving a String param instead.
444+
try {
445+
regions = params.resolveList(bdEndpoint.region, paramValues);
446+
} catch (err: any) {
447+
if (err instanceof ExprParseError) {
448+
regions = [params.resolveString(bdEndpoint.region, paramValues)];
449+
} else {
450+
throw err;
451+
}
452+
}
439453
}
440454
for (const region of regions) {
441455
const trigger = discoverTrigger(bdEndpoint, region, r);

0 commit comments

Comments
 (0)