Skip to content

Commit 6ff08fc

Browse files
authored
Use correct bucket name field when reading DefaultBucket for storage (#6420)
1 parent 6e9f56e commit 6ff08fc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/gcp/storage.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ interface ListBucketsResponse {
133133
];
134134
}
135135

136+
interface GetDefaultBucketResponse {
137+
name: string;
138+
location: string;
139+
bucket: {
140+
name: string;
141+
};
142+
}
143+
136144
/** Response type for obtaining the storage service agent */
137145
interface StorageServiceAccountResponse {
138146
email_address: string;
@@ -143,19 +151,19 @@ export async function getDefaultBucket(projectId: string): Promise<string> {
143151
await ensure(projectId, "firebasestorage.googleapis.com", "storage", false);
144152
try {
145153
const localAPIClient = new Client({ urlPrefix: firebaseStorageOrigin, apiVersion: "v1alpha" });
146-
const response = await localAPIClient.get<{ name: string }>(
154+
const response = await localAPIClient.get<GetDefaultBucketResponse>(
147155
`/projects/${projectId}/defaultBucket`
148156
);
149-
if (!response.body?.name) {
157+
if (!response.body?.bucket.name) {
150158
logger.debug("Default storage bucket is undefined.");
151159
throw new FirebaseError(
152160
"Your project is being set up. Please wait a minute before deploying again."
153161
);
154162
}
155-
return response.body.name;
163+
return response.body.bucket.name.split("/").pop()!;
156164
} catch (err: any) {
157165
logger.info(
158-
"\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."
166+
"\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."
159167
);
160168
throw err;
161169
}

0 commit comments

Comments
 (0)