From 94e5f379837d53187e8739eb048720fa054075f9 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 25 Feb 2026 17:22:10 +0000 Subject: [PATCH] fix: create project-thumbnails bucket in instrumentation.ts (#118) The thumbnail upload (uploadProjectThumbnail) writes to a 'project-thumbnails' storage bucket, but instrumentation.ts only bootstrapped the 'avatars' bucket. This caused: Upload failed: Bucket not found Add the missing bucket creation with matching constraints (public, 10 MB limit, image/png only). Also refactor the bucket-exists check to use a Set so it scales cleanly as more buckets are added. Co-authored-by: Anton Pascal --- apps/editor/instrumentation.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/editor/instrumentation.ts b/apps/editor/instrumentation.ts index 47f2b8cf..a5d0ddca 100644 --- a/apps/editor/instrumentation.ts +++ b/apps/editor/instrumentation.ts @@ -10,9 +10,9 @@ export async function register() { const supabase = createClient(url, key) const { data: buckets } = await supabase.storage.listBuckets() - const exists = buckets?.some((b) => b.name === 'avatars') + const bucketNames = new Set(buckets?.map((b) => b.name)) - if (!exists) { + if (!bucketNames.has('avatars')) { await supabase.storage.createBucket('avatars', { public: true, fileSizeLimit: 5 * 1024 * 1024, // 5MB @@ -20,5 +20,14 @@ export async function register() { }) console.log('Created "avatars" storage bucket') } + + if (!bucketNames.has('project-thumbnails')) { + await supabase.storage.createBucket('project-thumbnails', { + public: true, + fileSizeLimit: 10 * 1024 * 1024, // 10MB (matches uploadProjectThumbnail validation) + allowedMimeTypes: ['image/png'], + }) + console.log('Created "project-thumbnails" storage bucket') + } } }