AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Storage Explorer Search Filter Not Retained After Deletion

When filtering objects in the Storage explorer using the search box, deleting one or more of the filtered objects causes the file list to reset and display the full unfiltered bucket contents, while the search input still shows the filter text. This leaves the UI in an inconsistent state and may mislead users into thinking matching items still exist.

mediumConfidence 65%React

Origin Analysis

The deletion success handler likely refetches the file list without including the current search query parameter (or invalidates a query key that omits the search term), so the refreshed list contains all objects rather than the filtered subset.
1. Open Supabase Storage and select a bucket with multiple objects/prefixes. 2. Enter a search filter (e.g., '20260820') to show only matching objects. 3. Select one or more filtered objects and delete them. 4. Observe that after deletion, the list shows all objects while the search box still contains the filter text.

Fixing Code Block

const queryClient = useQueryClient(); const currentBucket = 'my-bucket'; const currentPrefix = ''; const searchQuery = '20260820'; const deleteFilesMutation = useMutation( async (files: FileItem[]) => { // Supabase Storage client v2 example const { error } = await supabase.storage .from(currentBucket) .remove(files.map(f => `${currentPrefix}/${f.name}`)); if (error) throw error; }, { onSuccess: () => { // Invalidate the exact query key that includes the search term queryClient.invalidateQueries([ 'storage-files', currentBucket, currentPrefix, searchQuery, ]); }, } );
The fix ensures that after a successful deletion, the file list query is invalidated using a query key that includes the current search filter. This triggers a refetch that respects the filter, keeping the displayed list consistent with the search input. The query key must include all relevant variables (bucket, prefix, search) so that invalidation targets the correct cached data.

Edge Case Audit

This fix assumes the file list query is keyed by bucket, prefix, and search. If other deletion paths (e.g., bulk delete button, keyboard shortcut, or context menu) do not invalidate the same key, the bug may persist in those flows. Additionally, if multiple deletions occur concurrently, the last invalidation might race with in-flight requests, potentially showing stale data. To avoid this, use a single mutation for batch deletion and ensure all deletion entry points route through it. Rollback instructions: if this fix introduces unexpected refetching behavior, revert to the previous deletion handler and ensure the search filter is explicitly passed to the refetch function as a parameter.

Ecosystem Topology