Skip to content

Commit

Permalink
Use correct bucket name field when reading DefaultBucket for storage (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
abhis3 committed Oct 2, 2023
1 parent 6e9f56e commit 6ff08fc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/gcp/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ interface ListBucketsResponse {
];
}

interface GetDefaultBucketResponse {
name: string;
location: string;
bucket: {
name: string;
};
}

/** Response type for obtaining the storage service agent */
interface StorageServiceAccountResponse {
email_address: string;
Expand All @@ -143,19 +151,19 @@ export async function getDefaultBucket(projectId: string): Promise<string> {
await ensure(projectId, "firebasestorage.googleapis.com", "storage", false);
try {
const localAPIClient = new Client({ urlPrefix: firebaseStorageOrigin, apiVersion: "v1alpha" });
const response = await localAPIClient.get<{ name: string }>(
const response = await localAPIClient.get<GetDefaultBucketResponse>(
`/projects/${projectId}/defaultBucket`
);
if (!response.body?.name) {
if (!response.body?.bucket.name) {
logger.debug("Default storage bucket is undefined.");
throw new FirebaseError(
"Your project is being set up. Please wait a minute before deploying again."
);
}
return response.body.name;
return response.body.bucket.name.split("/").pop()!;
} catch (err: any) {
logger.info(
"\n\nThere was an issue deploying your Storage rules. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support."
"\n\nThere was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support."
);
throw err;
}
Expand Down

0 comments on commit 6ff08fc

Please sign in to comment.