Skip to content

Commit c80567b

Browse files
committed
fix(supabase): tri-state bucket visibility on update, empty-string param coercion, introspect schema header
- introspect.ts now sends Accept-Profile when a schema param is given, matching the convention used by the other DB tools, so schema-scoped introspection actually reads from that schema's spec - storage_update_bucket.ts treats an empty-string param the same as "not provided" (e.g. an untouched file size limit input no longer coerces to 0) - the shared "Public Bucket" dropdown always sent an explicit true/false for storage_update_bucket (its default masked "not touched"), which could still flip a public bucket private; added a dedicated "Keep Current / True / False" control for the update operation so omitting a choice genuinely omits the isPublic override
1 parent 557e407 commit c80567b

3 files changed

Lines changed: 44 additions & 10 deletions

File tree

apps/sim/blocks/blocks/supabase.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,19 @@ Return ONLY the PostgREST filter expression - no explanations, no markdown, no e
923923
{ label: 'True (Public)', id: 'true' },
924924
],
925925
value: () => 'false',
926-
condition: { field: 'operation', value: ['storage_create_bucket', 'storage_update_bucket'] },
926+
condition: { field: 'operation', value: 'storage_create_bucket' },
927+
},
928+
{
929+
id: 'updateIsPublic',
930+
title: 'Public Bucket',
931+
type: 'dropdown',
932+
options: [
933+
{ label: 'Keep Current', id: '' },
934+
{ label: 'False (Private)', id: 'false' },
935+
{ label: 'True (Public)', id: 'true' },
936+
],
937+
value: () => '',
938+
condition: { field: 'operation', value: 'storage_update_bucket' },
927939
},
928940
{
929941
id: 'fileSizeLimit',
@@ -1065,6 +1077,7 @@ Return ONLY the PostgREST filter expression - no explanations, no markdown, no e
10651077
functionBody,
10661078
functionHeaders,
10671079
method,
1080+
updateIsPublic,
10681081
...rest
10691082
} = params
10701083

@@ -1237,6 +1250,16 @@ Return ONLY the PostgREST filter expression - no explanations, no markdown, no e
12371250
result.isPublic = parsedIsPublic
12381251
}
12391252

1253+
// "Keep Current" (empty string) means the caller didn't choose to
1254+
// override visibility — omit `isPublic` entirely so the update
1255+
// tool preserves the bucket's existing public/private setting
1256+
// instead of defaulting to false.
1257+
if (operation === 'storage_update_bucket' && updateIsPublic !== undefined) {
1258+
if (updateIsPublic === 'true' || updateIsPublic === 'false') {
1259+
result.isPublic = updateIsPublic === 'true'
1260+
}
1261+
}
1262+
12401263
if (normalizedFileData !== undefined) {
12411264
result.fileData = normalizedFileData
12421265
}
@@ -1291,6 +1314,11 @@ Return ONLY the PostgREST filter expression - no explanations, no markdown, no e
12911314
search: { type: 'string', description: 'Search term for filtering' },
12921315
expiresIn: { type: 'number', description: 'Expiration time in seconds for signed URL' },
12931316
isPublic: { type: 'boolean', description: 'Whether bucket should be public' },
1317+
updateIsPublic: {
1318+
type: 'string',
1319+
description:
1320+
'Visibility override for bucket update: "" keeps the current value, "true"/"false" overrides it',
1321+
},
12941322
fileSizeLimit: { type: 'number', description: 'Maximum file size in bytes' },
12951323
allowedMimeTypes: { type: 'array', description: 'Array of allowed MIME types' },
12961324
},

apps/sim/tools/supabase/introspect.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const introspectTool: ToolConfig<SupabaseIntrospectParams, SupabaseIntros
5757
apikey: params.apiKey,
5858
Authorization: `Bearer ${params.apiKey}`,
5959
Accept: 'application/openapi+json',
60+
...(params.schema ? { 'Accept-Profile': params.schema } : {}),
6061
}),
6162
},
6263

apps/sim/tools/supabase/storage_update_bucket.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,23 @@ export const storageUpdateBucketTool: ToolConfig<
107107

108108
const current = await currentResponse.json()
109109

110+
// Block subBlocks for a shared field can forward an empty string
111+
// (e.g. an untouched short-input) rather than omitting the key
112+
// entirely — treat that the same as "not provided" so it falls
113+
// back to the bucket's current value instead of coercing to 0/false.
114+
const hasValue = (value: unknown): boolean =>
115+
value !== undefined && value !== null && value !== ''
116+
110117
const payload: any = {
111118
id: params.bucket,
112119
name: params.bucket,
113-
public: params.isPublic !== undefined ? params.isPublic : Boolean(current.public),
114-
file_size_limit:
115-
params.fileSizeLimit !== undefined
116-
? Number(params.fileSizeLimit)
117-
: (current.file_size_limit ?? null),
118-
allowed_mime_types:
119-
params.allowedMimeTypes !== undefined
120-
? params.allowedMimeTypes
121-
: (current.allowed_mime_types ?? null),
120+
public: hasValue(params.isPublic) ? params.isPublic : Boolean(current.public),
121+
file_size_limit: hasValue(params.fileSizeLimit)
122+
? Number(params.fileSizeLimit)
123+
: (current.file_size_limit ?? null),
124+
allowed_mime_types: hasValue(params.allowedMimeTypes)
125+
? params.allowedMimeTypes
126+
: (current.allowed_mime_types ?? null),
122127
}
123128

124129
const updateResponse = await fetch(`${baseUrl}/storage/v1/bucket/${bucket}`, {

0 commit comments

Comments
 (0)