Skip to content

Commit 68125a7

Browse files
committed
fix(cloudflare): require explicit R2 lifecycle replacement rules
1 parent 4466fa2 commit 68125a7

5 files changed

Lines changed: 18 additions & 11 deletions

File tree

‎apps/docs/content/docs/integrations/cloudflare.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7744,7 +7744,7 @@ Replaces the object lifecycle rules for an R2 bucket. Rules match object-key pre
77447744
| `accountId` | string | Yes | Account id |
77457745
| `bucketName` | string | Yes | Bucket name |
77467746
| `apiKey` | string | Yes | Cloudflare API token |
7747-
| `rules` | json | No | JSON array. rules Fields: abortMultipartUploadsTransition, conditions, deleteObjectsTransition, enabled, id, storageClassTransitions. |
7747+
| `rules` | json | Yes | Complete JSON array of lifecycle rules. Read the current rules first and include every rule to retain. Use \[\] only to remove all lifecycle rules. Fields: abortMultipartUploadsTransition, conditions, deleteObjectsTransition, enabled, id, storageClassTransitions. |
77487748
| `jurisdiction` | string | No | Jurisdiction where objects in this bucket are guaranteed to be stored. |
77497749

77507750
#### Output

‎apps/sim/blocks/blocks/cloudflare.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,14 +4300,13 @@ export const CloudflareBlock: BlockConfig = {
43004300
id: 'r2BucketLifecycleRules',
43014301
title: 'Rules',
43024302
type: 'long-input',
4303-
placeholder: 'Enter rules as JSON',
4303+
placeholder: 'Enter all lifecycle rules as JSON; [] removes all rules',
43044304
condition: { field: 'operation', value: ['update_r2_bucket_lifecycle'] },
4305-
required: false,
4306-
mode: 'advanced',
4305+
required: true,
43074306
wandConfig: {
43084307
enabled: true,
43094308
prompt:
4310-
'Generate the Cloudflare rules value. JSON array. rules Fields: abortMultipartUploadsTransition, conditions, deleteObjectsTransition, enabled, id, storageClassTransitions. Return ONLY the value.',
4309+
'Generate the complete Cloudflare lifecycle rules JSON array. Include every existing rule the user wants to retain. Use [] only when the user wants to remove all lifecycle rules. Fields: abortMultipartUploadsTransition, conditions, deleteObjectsTransition, enabled, id, storageClassTransitions. Return ONLY the value.',
43114310
placeholder: 'Describe the rules',
43124311
},
43134312
},
@@ -5302,7 +5301,7 @@ export const CloudflareBlock: BlockConfig = {
53025301
r2BucketLifecycleRules: {
53035302
type: 'json',
53045303
description:
5305-
'JSON array. rules Fields: abortMultipartUploadsTransition, conditions, deleteObjectsTransition, enabled, id, storageClassTransitions.',
5304+
'Complete JSON array of lifecycle rules. Read the current rules first and include every rule to retain. Use [] only to remove all lifecycle rules. Fields: abortMultipartUploadsTransition, conditions, deleteObjectsTransition, enabled, id, storageClassTransitions.',
53065305
},
53075306
rulesetRulePosition: {
53085307
type: 'json',

‎apps/sim/tools/cloudflare/operation-types.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export interface CloudflareUpdateR2BucketLifecycleParams {
327327
accountId: string
328328
bucketName: string
329329
apiKey: string
330-
rules?: string | Record<string, unknown> | unknown[]
330+
rules: string | unknown[]
331331
jurisdiction?: string
332332
}
333333

‎apps/sim/tools/cloudflare/update_r2_bucket_lifecycle.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ export const updateR2BucketLifecycleTool: ToolConfig<
4141
},
4242
rules: {
4343
type: 'json',
44-
required: false,
44+
required: true,
4545
visibility: 'user-or-llm',
4646
description:
47-
'JSON array. rules Fields: abortMultipartUploadsTransition, conditions, deleteObjectsTransition, enabled, id, storageClassTransitions.',
47+
'Complete JSON array of lifecycle rules. Read the current rules first and include every rule to retain. Use [] only to remove all lifecycle rules. Fields: abortMultipartUploadsTransition, conditions, deleteObjectsTransition, enabled, id, storageClassTransitions.',
4848
},
4949
jurisdiction: {
5050
type: 'string',
@@ -61,7 +61,15 @@ export const updateR2BucketLifecycleTool: ToolConfig<
6161
...cloudflareHeaders(params.apiKey),
6262
...(params.jurisdiction ? { 'cf-r2-jurisdiction': params.jurisdiction } : {}),
6363
}),
64-
body: (params) => ({ rules: parseJsonArrayParam(params.rules, 'rules') }),
64+
body: (params) => {
65+
const rules = parseJsonArrayParam(params.rules, 'rules')
66+
if (rules === undefined) {
67+
throw new Error(
68+
'rules is required; supply a JSON array or [] to remove all lifecycle rules'
69+
)
70+
}
71+
return { rules }
72+
},
6573
},
6674
transformResponse: async (response) => {
6775
const data = await readCloudflareResponse(response)

‎apps/sim/tools/generated/tool-metadata.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)