Skip to content

Commit

Permalink
Improve error messages when trying to use alpha featuers without enab…
Browse files Browse the repository at this point in the history
…lement (#4354)

* Improve error messages when trying to use alpha featuers without enablement

* Changelog

* Run formatter
  • Loading branch information
inlined committed Apr 4, 2022
1 parent 226a0c2 commit 09c1bce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Improve error messages when using alpha features without being in the alpha program (#4354)
- Fixes bug where resumable uploads were not setting custom metadata on upload (#3398).
- Fixes bug where GCS metadataUpdate cloud functions were triggered in incorrect situations (#3398).
- Fixes bug where quoted escape sequences in .env files were incompletely unescaped. (#4270)
Expand Down
20 changes: 16 additions & 4 deletions src/deploy/functions/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as validate from "./validate";
import * as ensure from "./ensure";
import { Options } from "../../options";
import { functionMatchesAnyGroup, getFilterGroups } from "./functionsDeployHelper";
import { logBullet } from "../../utils";
import { logBullet, logLabeledError } from "../../utils";
import { getFunctionsConfig, prepareFunctionsUpload } from "./prepareFunctionsUpload";
import { promptForFailurePolicies, promptForMinInstances } from "./prompts";
import { needProjectId, needProjectNumber } from "../../projectUtils";
Expand All @@ -20,6 +20,7 @@ import { ensureTriggerRegions } from "./triggerRegionHelper";
import { ensureServiceAgentRoles } from "./checkIam";
import { FirebaseError } from "../../error";
import { normalizeAndValidate } from "../../functions/projectConfig";
import { previews } from "../../previews";

function hasUserConfig(config: Record<string, unknown>): boolean {
// "firebase" key is always going to exist in runtime config.
Expand Down Expand Up @@ -127,16 +128,27 @@ export async function prepare(
" directory for uploading..."
);
}
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv2")) {
if (!previews.functionsv2) {
throw new FirebaseError(
"This version of firebase-tools does not support Google Cloud " +
"Functions gen 2\n" +
"If Cloud Functions for Firebase gen 2 is still in alpha, sign up " +
"for the alpha program at " +
"https://services.google.com/fb/forms/firebasealphaprogram/\n" +
"If Cloud Functions for Firebase gen 2 is in beta, get the latest " +
"version of Firebse Tools with `npm i -g firebase-tools@latest`"
);
}
context.functionsSourceV2 = await prepareFunctionsUpload(sourceDir, context.config);
}
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv1")) {
context.functionsSourceV1 = await prepareFunctionsUpload(
sourceDir,
context.config,
runtimeConfig
);
}
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv2")) {
context.functionsSourceV2 = await prepareFunctionsUpload(sourceDir, context.config);
}

// Setup environment variables on each function.
for (const endpoint of backend.allEndpoints(wantBackend)) {
Expand Down

0 comments on commit 09c1bce

Please sign in to comment.