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

Fix bug where enabling API erroneously sent some payload. #4467

Merged
merged 3 commits into from
Apr 21, 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
@@ -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