Skip to content

Commit

Permalink
Better null handling for extensions want (#7576)
Browse files Browse the repository at this point in the history
  • Loading branch information
joehan authored Aug 21, 2024
1 parent e53da5c commit 1aa4f8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed an issue where functions deployment would fail if `firebase.json#extensions` was undefined. (#7575)
10 changes: 8 additions & 2 deletions src/deploy/extensions/planner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ export async function have(projectId: string): Promise<DeploymentInstanceSpec[]>
* any extensions the user has defined that way.
* @param args.projectId The project we are deploying to
* @param args.projectNumber The project number we are deploying to.
* @param args.extensions The extensions section of firebase.jsonm
* @param args.extensions The extensions section of firebase.json
* @param args.emulatorMode Whether the output will be used by the Extensions emulator.
* If true, this will check {instanceId}.env.local for params a
* If true, this will check {instanceId}.env.local for params
*/
export async function wantDynamic(args: {
projectId: string;
Expand All @@ -143,6 +143,9 @@ export async function wantDynamic(args: {
}): Promise<DeploymentInstanceSpec[]> {
const instanceSpecs: DeploymentInstanceSpec[] = [];
const errors: FirebaseError[] = [];
if (!args.extensions) {
return [];
}
for (const [instanceId, ext] of Object.entries(args.extensions)) {
const autoPopulatedParams = await getFirebaseProjectParams(args.projectId, args.emulatorMode);
const subbedParams = substituteParams(ext.params, autoPopulatedParams);
Expand Down Expand Up @@ -207,6 +210,9 @@ export async function want(args: {
}): Promise<DeploymentInstanceSpec[]> {
const instanceSpecs: DeploymentInstanceSpec[] = [];
const errors: FirebaseError[] = [];
if (!args.extensions) {
return [];
}
for (const e of Object.entries(args.extensions)) {
try {
const instanceId = e[0];
Expand Down
4 changes: 2 additions & 2 deletions src/deploy/extensions/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export async function prepareDynamicExtensions(
projectNumber,
aliases,
projectDir,
extensions: options.config.get("extensions"),
extensions: options.config.get("extensions", {}),
});
noDeleteExtensions = noDeleteExtensions.concat(firebaseJsonWant);
if (hasNonDeployingCodebases(options)) {
Expand Down Expand Up @@ -242,7 +242,7 @@ export async function prepare(context: Context, options: Options, payload: Paylo
projectNumber,
aliases,
projectDir,
extensions: options.config.get("extensions"),
extensions: options.config.get("extensions", {}),
});
const dynamicWant = await planner.wantDynamic({
projectId,
Expand Down

0 comments on commit 1aa4f8a

Please sign in to comment.