Skip to content

Commit 162e0cd

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(oci-document-understanding): normalize native block optional parameters
1 parent b977d67 commit 162e0cd

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

apps/sim/blocks/blocks/oci_document_understanding.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,12 @@ export const OciDocumentUnderstandingBlock: BlockConfig<OciDocumentResponse> = {
637637
if (typeof operation !== 'string' || !Object.hasOwn(OPERATION_FIELDS, operation))
638638
throw new Error('Select a Document Understanding operation')
639639
const output: Record<string, unknown> = {
640+
/** Explicit undefined values overwrite blank or inactive inputs in the executor merge. */
641+
...Object.fromEntries(
642+
Object.values(OPERATION_FIELDS)
643+
.flat()
644+
.map((key) => [key, undefined])
645+
),
640646
oauthCredential: params.oauthCredential,
641647
region: params.region || undefined,
642648
}

apps/sim/lib/internal/oci-document-understanding/execute-tool.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ vi.mock('@/lib/internal/oci-document-understanding/operations', () => ({
1111
import { OciClientError } from '@/lib/internal/oci/errors'
1212
import { executeOciDocumentTool } from '@/lib/internal/oci-document-understanding/execute-tool'
1313
import type { InternalToolOperationCall } from '@/lib/internal/tool-operations/types'
14+
import { OciDocumentUnderstandingBlock } from '@/blocks/blocks/oci_document_understanding'
15+
import { ociDocumentListModelsTool } from '@/tools/oci_document_understanding/list_models'
1416
import {
1517
documentOperationInput,
1618
isDocumentJsonWithinLimit,
@@ -39,6 +41,42 @@ describe('document internal tool boundary', () => {
3941
executeOperation.mockResolvedValue({ success: true, output: {} })
4042
})
4143

44+
it.each([null, '', undefined, 'project-1'])(
45+
'normalizes an optional project filter through the native block merge (%s)',
46+
async (projectId) => {
47+
const raw = {
48+
operation: ociDocumentListModelsTool.id,
49+
oauthCredential: 'selected',
50+
compartmentId: 'compartment-1',
51+
projectId,
52+
displayName: null,
53+
page: '',
54+
limit: '10',
55+
}
56+
const params = {
57+
...raw,
58+
...OciDocumentUnderstandingBlock.tools.config?.params?.(raw),
59+
accessToken: 'authorized',
60+
}
61+
const response = await executeOciDocumentTool(
62+
request('list_models', ociDocumentListModelsTool.operation.input(params))
63+
)
64+
expect(response.status).toBe(200)
65+
expect(executeOperation).toHaveBeenCalledWith(
66+
expect.objectContaining({
67+
operation: 'list_models',
68+
credentialId: 'authorized',
69+
compartmentId: 'compartment-1',
70+
limit: 10,
71+
}),
72+
expect.anything()
73+
)
74+
expect(executeOperation.mock.lastCall?.[0].projectId).toBe(projectId || undefined)
75+
expect(executeOperation.mock.lastCall?.[0].displayName).toBeUndefined()
76+
expect(executeOperation.mock.lastCall?.[0].page).toBeUndefined()
77+
}
78+
)
79+
4280
it.each([
4381
['analyze_document', analysisInput],
4482
[

0 commit comments

Comments
 (0)