Skip to content

Commit 1aa4f8a

Browse files
authored
Better null handling for extensions want (#7576)
1 parent e53da5c commit 1aa4f8a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixed an issue where functions deployment would fail if `firebase.json#extensions` was undefined. (#7575)

src/deploy/extensions/planner.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ export async function have(projectId: string): Promise<DeploymentInstanceSpec[]>
131131
* any extensions the user has defined that way.
132132
* @param args.projectId The project we are deploying to
133133
* @param args.projectNumber The project number we are deploying to.
134-
* @param args.extensions The extensions section of firebase.jsonm
134+
* @param args.extensions The extensions section of firebase.json
135135
* @param args.emulatorMode Whether the output will be used by the Extensions emulator.
136-
* If true, this will check {instanceId}.env.local for params a
136+
* If true, this will check {instanceId}.env.local for params
137137
*/
138138
export async function wantDynamic(args: {
139139
projectId: string;
@@ -143,6 +143,9 @@ export async function wantDynamic(args: {
143143
}): Promise<DeploymentInstanceSpec[]> {
144144
const instanceSpecs: DeploymentInstanceSpec[] = [];
145145
const errors: FirebaseError[] = [];
146+
if (!args.extensions) {
147+
return [];
148+
}
146149
for (const [instanceId, ext] of Object.entries(args.extensions)) {
147150
const autoPopulatedParams = await getFirebaseProjectParams(args.projectId, args.emulatorMode);
148151
const subbedParams = substituteParams(ext.params, autoPopulatedParams);
@@ -207,6 +210,9 @@ export async function want(args: {
207210
}): Promise<DeploymentInstanceSpec[]> {
208211
const instanceSpecs: DeploymentInstanceSpec[] = [];
209212
const errors: FirebaseError[] = [];
213+
if (!args.extensions) {
214+
return [];
215+
}
210216
for (const e of Object.entries(args.extensions)) {
211217
try {
212218
const instanceId = e[0];

src/deploy/extensions/prepare.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export async function prepareDynamicExtensions(
188188
projectNumber,
189189
aliases,
190190
projectDir,
191-
extensions: options.config.get("extensions"),
191+
extensions: options.config.get("extensions", {}),
192192
});
193193
noDeleteExtensions = noDeleteExtensions.concat(firebaseJsonWant);
194194
if (hasNonDeployingCodebases(options)) {
@@ -242,7 +242,7 @@ export async function prepare(context: Context, options: Options, payload: Paylo
242242
projectNumber,
243243
aliases,
244244
projectDir,
245-
extensions: options.config.get("extensions"),
245+
extensions: options.config.get("extensions", {}),
246246
});
247247
const dynamicWant = await planner.wantDynamic({
248248
projectId,

0 commit comments

Comments
 (0)