Skip to content

Commit 1fa7b10

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(oci-object-storage-native): normalize native block optional parameters
1 parent ceae761 commit 1fa7b10

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

apps/sim/blocks/blocks/oci_object_storage_native.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,12 @@ export const OciObjectStorageNativeBlock: BlockConfig<OciObjectStorageNativeResp
17051705
operationParams.objectName = params.scope === 'bucket' ? undefined : params.grantObject
17061706
}
17071707
const result: Record<string, unknown> = {
1708+
/** Explicitly unset absent semantic inputs because the executor merges this patch. */
1709+
...Object.fromEntries(
1710+
Object.values(OPERATION_FIELDS)
1711+
.flat()
1712+
.map((field) => [field, undefined])
1713+
),
17081714
oauthCredential: params.oauthCredential,
17091715
region: params.region || undefined,
17101716
namespace: params.namespace || undefined,

apps/sim/lib/internal/oci-object-storage-native/execute-tool.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { OciClientError } from '@/lib/internal/oci/errors'
88
import { executeOciObjectStorageNativeTool } from '@/lib/internal/oci-object-storage-native/execute-tool'
99
import type { InternalToolOperationCall } from '@/lib/internal/tool-operations/types'
1010
import { MAX_BUFFERED_TRANSFER_BYTES } from '@/lib/uploads/shared/types'
11+
import { OciObjectStorageNativeBlock } from '@/blocks/blocks/oci_object_storage_native'
12+
import { ociObjectStorageNativeGetNamespaceTool } from '@/tools/oci_object_storage_native/get_namespace'
1113
import {
1214
createOciNativeOperationInput,
1315
OCI_NATIVE_JSON_BYTES,
@@ -85,6 +87,48 @@ describe('native OCI tool operation handler', () => {
8587
mocks.executeOciNativeOperation.mockResolvedValue({ success: true, output: {} })
8688
})
8789

90+
it.each([null, '', undefined, 'compartment'])(
91+
'normalizes the optional namespace compartment through native merge (%s)',
92+
async (compartmentId) => {
93+
const raw = {
94+
operation: ociObjectStorageNativeGetNamespaceTool.id,
95+
oauthCredential: 'selected',
96+
compartmentId,
97+
}
98+
const params = {
99+
...raw,
100+
...OciObjectStorageNativeBlock.tools.config?.params?.(raw),
101+
accessToken: 'authorized',
102+
}
103+
const response = await executeOciObjectStorageNativeTool(
104+
request('get_namespace', ociObjectStorageNativeGetNamespaceTool.operation.input(params))
105+
)
106+
expect(response.status).toBe(200)
107+
expect(mocks.executeOciNativeOperation).toHaveBeenCalledWith(
108+
expect.objectContaining({
109+
credentialId: 'authorized',
110+
}),
111+
expect.anything()
112+
)
113+
expect(mocks.executeOciNativeOperation.mock.lastCall?.[0].compartmentId).toBe(
114+
compartmentId || undefined
115+
)
116+
}
117+
)
118+
119+
it('preserves zero-byte inline upload content when suppressing inactive fields', () => {
120+
const raw = {
121+
operation: 'oci_object_storage_native_upload_object',
122+
uploadSource: 'content',
123+
content: '',
124+
file: { id: 'stale' },
125+
newObjectName: 'empty.txt',
126+
}
127+
const params = { ...raw, ...OciObjectStorageNativeBlock.tools.config?.params?.(raw) }
128+
expect(params.content).toBe('')
129+
expect(params.file).toBeUndefined()
130+
})
131+
88132
it.each(CASES)(
89133
'validates and dispatches %s with trusted workspace context',
90134
async (operation, input) => {

0 commit comments

Comments
 (0)