Skip to content

Commit

Permalink
Fix bug where enabling API erroneously sent some payload. (#4467)
Browse files Browse the repository at this point in the history
The options we were including to suppresses superfluously log entries whenever we enable GCP API were being sent as payload to the POST request.

Fixes #4465
  • Loading branch information
taeold committed Apr 21, 2022
1 parent 347a215 commit f895a40
Show file tree
Hide file tree
Showing 3 changed files with 9 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 @@
- Fixes bug where API enablement failed. (#4467)
10 changes: 7 additions & 3 deletions src/ensureApiEnabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ export async function check(
*/
async function enable(projectId: string, apiName: string): Promise<void> {
try {
await apiClient.post(`/projects/${projectId}/services/${apiName}:enable`, {
skipLog: { resBody: true },
});
await apiClient.post<undefined, unknown>(
`/projects/${projectId}/services/${apiName}:enable`,
undefined,
{
skipLog: { resBody: true },
}
);
} catch (err: any) {
if (isBillingError(err)) {
throw new FirebaseError(`Your project ${bold(
Expand Down
2 changes: 1 addition & 1 deletion src/test/ensureApiEnabled.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe("ensureApiEnabled", () => {
.reply(200, { state: "DISABLED" });

nock("https://serviceusage.googleapis.com")
.post(`/v1/projects/${FAKE_PROJECT_ID}/services/${FAKE_API}:enable`)
.post(`/v1/projects/${FAKE_PROJECT_ID}/services/${FAKE_API}:enable`, (body) => !body)
.once()
.reply(200);

Expand Down

0 comments on commit f895a40

Please sign in to comment.