Skip to content

Commit c1a6bf2

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(oci-resource-manager): normalize native block optional parameters
1 parent 48ef0e7 commit c1a6bf2

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

apps/sim/blocks/blocks/oci_resource_manager.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,16 @@ export const OciResourceManagerBlock: BlockConfig<OciResourceManagerResponse> =
14361436
? params.jobLogKind
14371437
: params.workLogKind
14381438
: params[key]
1439-
if (value === undefined || value === '') continue
1439+
if (
1440+
value === undefined ||
1441+
value === '' ||
1442+
(value === null &&
1443+
action.startsWith('list_') &&
1444+
['displayName', 'templateId', 'configurationSourceProviderId'].includes(key))
1445+
) {
1446+
result[key] = undefined
1447+
continue
1448+
}
14401449
if (
14411450
[
14421451
'configSource',

apps/sim/lib/internal/oci-resource-manager/execute-tool.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ vi.mock('@/lib/internal/oci-resource-manager/operations', () => ({
2828

2929
import { executeOciResourceManagerTool } from '@/lib/internal/oci-resource-manager/execute-tool'
3030
import type { InternalToolOperationCall } from '@/lib/internal/tool-operations/types'
31+
import { OciResourceManagerBlock } from '@/blocks/blocks/oci_resource_manager'
32+
import { ociResourceManagerListConfigurationSourceProvidersTool } from '@/tools/oci_resource_manager/list_configuration_source_providers'
33+
import { ociResourceManagerListStacksTool } from '@/tools/oci_resource_manager/list_stacks'
34+
import { ociResourceManagerListTemplatesTool } from '@/tools/oci_resource_manager/list_templates'
3135

3236
function request(overrides: Partial<InternalToolOperationCall> = {}): InternalToolOperationCall {
3337
return {
@@ -59,6 +63,46 @@ beforeEach(() => {
5963
})
6064
})
6165
describe('Resource Manager execution authorization', () => {
66+
it.each([
67+
['list_stacks', ociResourceManagerListStacksTool, {}],
68+
[
69+
'list_templates',
70+
ociResourceManagerListTemplatesTool,
71+
{ templateId: null, templateCategoryId: '0' },
72+
],
73+
[
74+
'list_configuration_source_providers',
75+
ociResourceManagerListConfigurationSourceProvidersTool,
76+
{ configurationSourceProviderId: null },
77+
],
78+
] as const)(
79+
'omits blank optional filters through the native %s block merge',
80+
async (operation, tool, extra) => {
81+
const raw = {
82+
operation,
83+
oauthCredential: 'supplied',
84+
compartmentId: 'compartment',
85+
displayName: null,
86+
page: '',
87+
selectorCompartmentId: null,
88+
...extra,
89+
}
90+
const params = { ...raw, ...OciResourceManagerBlock.tools.config?.params?.(raw) }
91+
const response = await executeOciResourceManagerTool(
92+
request({ toolId: tool.id, input: tool.operation.input(params) })
93+
)
94+
expect(response.status).toBe(200)
95+
expect(mocks.execute).toHaveBeenCalledWith(
96+
operation,
97+
expect.objectContaining({
98+
compartmentId: 'compartment',
99+
displayName: undefined,
100+
page: undefined,
101+
}),
102+
expect.anything()
103+
)
104+
}
105+
)
62106
it('uses only the authorized credential ID and trusted workspace/actor', async () => {
63107
expect((await executeOciResourceManagerTool(request())).status).toBe(200)
64108
expect(mocks.authorize).toHaveBeenCalledWith(expect.objectContaining({ userId: 'actor' }), {

0 commit comments

Comments
 (0)