Skip to content

Commit bd490b8

Browse files
waleedlatif1claude
andcommitted
fix(blocks): align canonicalParamId with tool param name for file inputs
Renames the canonical id from `document` to `file` on firecrawl, reducto v2, pulse v2, and extend v2 so pre-execution validation resolves the value under the same key the tool expects, eliminating false "missing required fields: file" errors at submit time. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent afadcf5 commit bd490b8

4 files changed

Lines changed: 43 additions & 24 deletions

File tree

apps/sim/blocks/blocks/extend.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,27 @@ export const ExtendBlock: BlockConfig<ExtendParserOutput> = {
130130
},
131131
}
132132

133-
const extendV2Inputs = ExtendBlock.inputs
133+
// ExtendV2Block renames the canonical id to `file` so it matches the tool param name
134+
// and pre-execution validation can resolve the value without invoking the params mapper.
135+
const extendV2Inputs = {
136+
file: { type: 'json' as const, description: 'Document (file upload or file reference)' },
137+
apiKey: ExtendBlock.inputs?.apiKey,
138+
outputFormat: ExtendBlock.inputs?.outputFormat,
139+
chunking: ExtendBlock.inputs?.chunking,
140+
engine: ExtendBlock.inputs?.engine,
141+
}
134142
const extendV2SubBlocks = (ExtendBlock.subBlocks || []).flatMap((subBlock) => {
135143
if (subBlock.id === 'filePath') {
136144
return []
137145
}
138146
if (subBlock.id === 'fileUpload') {
139147
return [
140-
subBlock,
148+
{ ...subBlock, canonicalParamId: 'file' },
141149
{
142150
id: 'fileReference',
143151
title: 'Document',
144152
type: 'short-input' as SubBlockType,
145-
canonicalParamId: 'document',
153+
canonicalParamId: 'file',
146154
placeholder: 'Connect a file output from another block',
147155
mode: 'advanced' as const,
148156
required: true,
@@ -173,7 +181,7 @@ export const ExtendV2Block: BlockConfig<ExtendParserOutput> = {
173181
apiKey: params.apiKey.trim(),
174182
}
175183

176-
const documentInput = normalizeFileInput(params.document, { single: true })
184+
const documentInput = normalizeFileInput(params.file, { single: true })
177185
if (!documentInput) {
178186
throw new Error('Document file is required')
179187
}

apps/sim/blocks/blocks/firecrawl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const FirecrawlBlock: BlockConfig<FirecrawlResponse> = {
3737
id: 'fileUpload',
3838
title: 'Document',
3939
type: 'file-upload' as SubBlockType,
40-
canonicalParamId: 'document',
40+
canonicalParamId: 'file',
4141
acceptedTypes:
4242
'application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword,application/vnd.oasis.opendocument.text,application/rtf,text/rtf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/html',
4343
placeholder: 'Upload a document (PDF, DOCX, HTML, XLSX, etc.)',
@@ -53,7 +53,7 @@ export const FirecrawlBlock: BlockConfig<FirecrawlResponse> = {
5353
id: 'fileReference',
5454
title: 'File Reference',
5555
type: 'short-input' as SubBlockType,
56-
canonicalParamId: 'document',
56+
canonicalParamId: 'file',
5757
placeholder: 'File reference from previous block',
5858
mode: 'advanced',
5959
condition: {
@@ -487,7 +487,7 @@ Example 2 - Product Data:
487487
break
488488

489489
case 'parse': {
490-
const file = normalizeFileInput(params.document, { single: true })
490+
const file = normalizeFileInput(params.file, { single: true })
491491
if (!file) {
492492
throw new Error('A document file is required for the parse operation')
493493
}
@@ -624,7 +624,7 @@ Example 2 - Product Data:
624624
},
625625
maxCredits: { type: 'number', description: 'Maximum credits to spend' },
626626
strictConstrainToURLs: { type: 'boolean', description: 'Limit agent to provided URLs only' },
627-
document: { type: 'json', description: 'Document input (file upload or file reference)' },
627+
file: { type: 'json', description: 'Document input (file upload or file reference)' },
628628
includeTags: { type: 'json', description: 'HTML tags to include during parsing' },
629629
excludeTags: { type: 'json', description: 'HTML tags to exclude during parsing' },
630630
parsers: { type: 'json', description: 'Parser configuration (e.g., [{"type": "pdf"}])' },

apps/sim/blocks/blocks/pulse.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,27 @@ export const PulseBlock: BlockConfig<PulseParserOutput> = {
128128
},
129129
}
130130

131-
// PulseV2Block uses the same canonical param 'document' for both basic and advanced modes
132-
const pulseV2Inputs = PulseBlock.inputs
131+
// PulseV2Block renames the canonical id to `file` so it matches the tool param name
132+
// and pre-execution validation can resolve the value without invoking the params mapper.
133+
const pulseV2Inputs = {
134+
file: { type: 'json' as const, description: 'Document (file upload or file reference)' },
135+
apiKey: PulseBlock.inputs?.apiKey,
136+
pages: PulseBlock.inputs?.pages,
137+
chunking: PulseBlock.inputs?.chunking,
138+
chunkSize: PulseBlock.inputs?.chunkSize,
139+
}
133140
const pulseV2SubBlocks = (PulseBlock.subBlocks || []).flatMap((subBlock) => {
134141
if (subBlock.id === 'filePath') {
135-
return [] // Remove the old filePath subblock
142+
return []
136143
}
137144
if (subBlock.id === 'fileUpload') {
138-
// Insert fileReference right after fileUpload
139145
return [
140-
subBlock,
146+
{ ...subBlock, canonicalParamId: 'file' },
141147
{
142148
id: 'fileReference',
143149
title: 'Document',
144150
type: 'short-input' as SubBlockType,
145-
canonicalParamId: 'document',
151+
canonicalParamId: 'file',
146152
placeholder: 'File reference',
147153
mode: 'advanced' as const,
148154
required: true,
@@ -173,8 +179,7 @@ export const PulseV2Block: BlockConfig<PulseParserOutput> = {
173179
apiKey: params.apiKey.trim(),
174180
}
175181

176-
// document is the canonical param from fileUpload (basic) or fileReference (advanced)
177-
const normalizedFile = normalizeFileInput(params.document, { single: true })
182+
const normalizedFile = normalizeFileInput(params.file, { single: true })
178183
if (!normalizedFile) {
179184
throw new Error('Document file is required')
180185
}

apps/sim/blocks/blocks/reducto.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,27 @@ export const ReductoBlock: BlockConfig<ReductoParserOutput> = {
135135
},
136136
}
137137

138-
// ReductoV2Block uses the same canonical param 'document' for both basic and advanced modes
139-
const reductoV2Inputs = ReductoBlock.inputs
138+
// ReductoV2Block drops V1's URL filePath input and exposes file upload + file reference
139+
// as a single canonical group. The canonical id matches the tool param name (`file`) so
140+
// pre-execution validation can resolve the value without invoking the params mapper.
141+
const reductoV2Inputs = {
142+
file: { type: 'json' as const, description: 'PDF document (file upload or file reference)' },
143+
apiKey: ReductoBlock.inputs?.apiKey,
144+
pages: ReductoBlock.inputs?.pages,
145+
tableOutputFormat: ReductoBlock.inputs?.tableOutputFormat,
146+
}
140147
const reductoV2SubBlocks = (ReductoBlock.subBlocks || []).flatMap((subBlock) => {
141148
if (subBlock.id === 'filePath') {
142149
return []
143150
}
144151
if (subBlock.id === 'fileUpload') {
145152
return [
146-
subBlock,
153+
{ ...subBlock, canonicalParamId: 'file' },
147154
{
148155
id: 'fileReference',
149156
title: 'PDF Document',
150157
type: 'short-input' as SubBlockType,
151-
canonicalParamId: 'document',
158+
canonicalParamId: 'file',
152159
placeholder: 'File reference',
153160
mode: 'advanced' as const,
154161
required: true,
@@ -178,12 +185,11 @@ export const ReductoV2Block: BlockConfig<ReductoParserOutput> = {
178185
apiKey: params.apiKey.trim(),
179186
}
180187

181-
// document is the canonical param from fileUpload (basic) or fileReference (advanced)
182-
const documentInput = normalizeFileInput(params.document, { single: true })
183-
if (!documentInput) {
188+
const fileInput = normalizeFileInput(params.file, { single: true })
189+
if (!fileInput) {
184190
throw new Error('PDF document file is required')
185191
}
186-
parameters.file = documentInput
192+
parameters.file = fileInput
187193

188194
let pagesArray: number[] | undefined
189195
if (params.pages && params.pages.trim() !== '') {

0 commit comments

Comments
 (0)