Skip to content

Commit bae7922

Browse files
authored
Add try catches in post delete analytics bucket clean up (supabase#39969)
1 parent ec27332 commit bae7922

File tree

4 files changed

+45
-24
lines changed

4 files changed

+45
-24
lines changed

apps/studio/components/interfaces/Storage/AnalyticsBucketDetails/useAnalyticsBucketAssociatedEntities.tsx

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,17 @@ export const useAnalyticsBucketAssociatedEntities = (
6666
}
6767

6868
export const useAnalyticsBucketDeleteCleanUp = () => {
69-
const { mutateAsync: deleteFDW, isLoading: isDeletingWrapper } = useFDWDeleteMutation()
69+
const { mutateAsync: deleteFDW, isLoading: isDeletingWrapper } = useFDWDeleteMutation({
70+
// Silence default error handler toast
71+
onError: () => {},
72+
})
7073

71-
const { mutateAsync: deleteS3AccessKey, isLoading: isDeletingKey } =
72-
useS3AccessKeyDeleteMutation()
74+
const { mutateAsync: deleteS3AccessKey, isLoading: isDeletingKey } = useS3AccessKeyDeleteMutation(
75+
{
76+
// Silence default error handler toast
77+
onError: () => {},
78+
}
79+
)
7380

7481
const isDeleting = isDeletingWrapper || isDeletingKey
7582

@@ -91,26 +98,38 @@ export const useAnalyticsBucketDeleteCleanUp = () => {
9198
publication?: ReplicationPublication
9299
}) => {
93100
if (!!icebergWrapper && !!icebergWrapperMeta) {
94-
await deleteFDW({
95-
projectRef,
96-
connectionString,
97-
wrapper: icebergWrapper,
98-
wrapperMeta: icebergWrapperMeta,
99-
})
101+
try {
102+
await deleteFDW({
103+
projectRef,
104+
connectionString,
105+
wrapper: icebergWrapper,
106+
wrapperMeta: icebergWrapperMeta,
107+
})
108+
} catch (error: any) {
109+
console.error(`Failed to delete iceberg wrapper for ${bucketId}:`, error.message)
110+
}
100111
} else {
101112
console.warn(`Unable to find and delete iceberg wrapper for ${bucketId}`)
102113
}
103114

104115
if (!!s3AccessKey) {
105-
await deleteS3AccessKey({ projectRef, id: s3AccessKey.id })
116+
try {
117+
await deleteS3AccessKey({ projectRef, id: s3AccessKey.id })
118+
} catch (error: any) {
119+
console.error(`Failed to delete S3 access key for: ${bucketId}`, error.message)
120+
}
106121
} else {
107122
console.warn(`Unable to find and delete corresponding S3 access key for ${bucketId}`)
108123
}
109124

110125
if (!!publication) {
111-
// [TODO] Delete the publication
126+
try {
127+
// [TODO] Delete the publication
128+
} catch (error: any) {
129+
console.error(`Failed to delete replication publication for: ${bucketId}`, error.message)
130+
}
112131
} else {
113-
console.log(`Unable to find and delete corresponding publication for ${bucketId}`)
132+
console.warn(`Unable to find and delete replication publication for ${bucketId}`)
114133
}
115134
}
116135

apps/studio/components/interfaces/Storage/CreateBucketModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export const CreateBucketModal = ({
265265
</ButtonTooltip>
266266
</DialogTrigger>
267267

268-
<DialogContent>
268+
<DialogContent aria-describedby={undefined}>
269269
<DialogHeader>
270270
<DialogTitle>Create a {isStorageV2 ? config.singularName : 'storage'} bucket</DialogTitle>
271271
</DialogHeader>

apps/studio/components/interfaces/Storage/CreateSpecializedBucketModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export const CreateSpecializedBucketModal = ({
227227
</ButtonTooltip>
228228
</DialogTrigger>
229229

230-
<DialogContent>
230+
<DialogContent aria-describedby={undefined}>
231231
<DialogHeader>
232232
<DialogTitle>Create {config.singularName} bucket</DialogTitle>
233233
</DialogHeader>

apps/studio/components/interfaces/Storage/DeleteBucketModal.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,17 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
127127
const { mutate: deleteAnalyticsBucket, isLoading: isDeletingAnalyticsBucket } =
128128
useAnalyticsBucketDeleteMutation({
129129
onSuccess: async () => {
130-
await deleteAnalyticsBucketCleanUp({
131-
projectRef,
132-
bucketId: bucket.id,
133-
icebergWrapper,
134-
icebergWrapperMeta,
135-
s3AccessKey,
136-
publication,
137-
})
138-
130+
if (project?.connectionString) {
131+
await deleteAnalyticsBucketCleanUp({
132+
projectRef,
133+
connectionString: project.connectionString,
134+
bucketId: bucket.id,
135+
icebergWrapper,
136+
icebergWrapperMeta,
137+
s3AccessKey,
138+
publication,
139+
})
140+
}
139141
toast.success(`Successfully deleted analytics bucket ${bucket.id}`)
140142
if (isStorageV2) {
141143
router.push(`/project/${projectRef}/storage/analytics`)
@@ -171,7 +173,7 @@ export const DeleteBucketModal = ({ visible, bucket, onClose }: DeleteBucketModa
171173
if (!open) onClose()
172174
}}
173175
>
174-
<DialogContent>
176+
<DialogContent aria-describedby={undefined}>
175177
<DialogHeader>
176178
<DialogTitle>Confirm deletion of {bucket.id}</DialogTitle>
177179
</DialogHeader>

0 commit comments

Comments
 (0)