Skip to content

Commit dfe14bf

Browse files
committed
fix(textract): stop stale processingMode from hiding ID document fields
- Front-document fields (fileUpload/fileReference) are shared across all 3 operations; gate them with a values-aware condition so switching to Analyze Identity Document keeps them visible even if a stale processingMode='async' is left over from a previous operation - S3 URI field now also requires operation !== 'analyze_id', since that operation never supports S3 input
1 parent dbc9c0f commit dfe14bf

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

apps/sim/blocks/blocks/textract.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,18 @@ export const TextractBlock: BlockConfig<TextractParserOutput> = {
199199
},
200200
}
201201

202+
/**
203+
* The front-document fields (fileUpload/fileReference) are shared by all three operations.
204+
* Analyze Identity Document is always synchronous, so they must stay visible for it regardless
205+
* of a stale `processingMode` value left over from switching away from another operation.
206+
*/
207+
function documentFieldCondition(values?: Record<string, unknown>) {
208+
if (values?.operation === 'analyze_id') {
209+
return { field: 'operation', value: 'analyze_id' } as const
210+
}
211+
return { field: 'processingMode', value: 'async', not: true } as const
212+
}
213+
202214
/**
203215
* Resolves a canonical document input to either an uploaded file object or a plain URL string.
204216
* `normalizeFileInput` only recognizes file objects (or JSON-serialized file references) — a raw
@@ -260,7 +272,7 @@ export const TextractV2Block: BlockConfig<TextractParserOutput> = {
260272
canonicalParamId: 'document',
261273
acceptedTypes: 'image/jpeg,image/png,application/pdf',
262274
placeholder: 'Upload JPEG, PNG, or single-page PDF (max 10MB)',
263-
condition: { field: 'processingMode', value: 'async', not: true },
275+
condition: documentFieldCondition,
264276
mode: 'basic',
265277
maxSize: 10,
266278
},
@@ -270,7 +282,7 @@ export const TextractV2Block: BlockConfig<TextractParserOutput> = {
270282
type: 'short-input' as SubBlockType,
271283
canonicalParamId: 'document',
272284
placeholder: 'File reference',
273-
condition: { field: 'processingMode', value: 'async', not: true },
285+
condition: documentFieldCondition,
274286
mode: 'advanced' as const,
275287
},
276288
{
@@ -298,7 +310,11 @@ export const TextractV2Block: BlockConfig<TextractParserOutput> = {
298310
title: 'S3 URI',
299311
type: 'short-input' as SubBlockType,
300312
placeholder: 's3://bucket-name/path/to/document.pdf',
301-
condition: { field: 'processingMode', value: 'async' },
313+
condition: {
314+
field: 'processingMode',
315+
value: 'async',
316+
and: { field: 'operation', value: 'analyze_id', not: true },
317+
},
302318
},
303319
{
304320
id: 'region',

0 commit comments

Comments
 (0)