Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages when trying to use alpha featuers without enablement #4354

Merged
merged 4 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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