Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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