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

Use correct bucket name field when reading DefaultBucket for storage #6420

Merged
merged 1 commit into from
Oct 2, 2023
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."
abhis3 marked this conversation as resolved.
Show resolved Hide resolved
);
throw err;
}
Expand Down