Skip to content

Commit 802803c

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(oci-monitoring): address CI formatting and header typing
1 parent 4df2d3f commit 802803c

15 files changed

Lines changed: 655 additions & 295 deletions

File tree

apps/sim/blocks/blocks/oci_monitoring.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,26 @@ export const OciMonitoringBlock: BlockConfig<OciMonitoringResponse> = {
3030
list_alarms_status: ['List alarm statuses', { text: 'matching', field: 'status' }],
3131
get_alarm: [{ text: 'Get alarm', field: ALARM_FIELD, core: true }],
3232
get_alarm_history: [{ text: 'Read history for', field: ALARM_FIELD, core: true }],
33-
retrieve_dimension_states: [{ text: 'Inspect dimension states for', field: ALARM_FIELD, core: true }],
33+
retrieve_dimension_states: [
34+
{ text: 'Inspect dimension states for', field: ALARM_FIELD, core: true },
35+
],
3436
create_alarm: [{ text: 'Create alarm', field: 'displayName', core: true }],
3537
update_alarm: [{ text: 'Update alarm', field: ALARM_FIELD, core: true }],
3638
delete_alarm: [{ text: 'Delete alarm', field: ALARM_FIELD, core: true }],
3739
create_alarm_suppression: [{ text: 'Suppress alarm', field: ALARM_FIELD, core: true }],
38-
list_alarm_suppressions: [{ text: 'List suppressions for', field: ALARM_FIELD, core: true }],
40+
list_alarm_suppressions: [
41+
{ text: 'List suppressions for', field: ALARM_FIELD, core: true },
42+
],
3943
get_alarm_suppression: [{ text: 'Get suppression', field: SUPPRESSION_FIELD, core: true }],
40-
delete_alarm_suppression: [{ text: 'Delete suppression', field: SUPPRESSION_FIELD, core: true }],
41-
summarize_alarm_suppression_history: [{ text: 'Read suppression history for', field: ALARM_FIELD, core: true }],
42-
remove_alarm_suppression: [{ text: 'Remove inline suppression from', field: ALARM_FIELD, core: true }],
44+
delete_alarm_suppression: [
45+
{ text: 'Delete suppression', field: SUPPRESSION_FIELD, core: true },
46+
],
47+
summarize_alarm_suppression_history: [
48+
{ text: 'Read suppression history for', field: ALARM_FIELD, core: true },
49+
],
50+
remove_alarm_suppression: [
51+
{ text: 'Remove inline suppression from', field: ALARM_FIELD, core: true },
52+
],
4353
},
4454
},
4555
},
@@ -791,8 +801,7 @@ export const OciMonitoringBlock: BlockConfig<OciMonitoringResponse> = {
791801
placeholder: 'JSON array of up to two alarm trigger-rule overrides.',
792802
wandConfig: {
793803
enabled: true,
794-
prompt:
795-
'JSON array of up to two alarm trigger-rule overrides. Return ONLY the JSON array.',
804+
prompt: 'JSON array of up to two alarm trigger-rule overrides. Return ONLY the JSON array.',
796805
placeholder: 'Describe the desired value',
797806
generationType: 'json-array',
798807
},
@@ -1061,7 +1070,13 @@ export const OciMonitoringBlock: BlockConfig<OciMonitoringResponse> = {
10611070
result[key] = Number(result[key])
10621071
}
10631072
}
1064-
for (const key of ['compartmentIdInSubtree', 'metricCompartmentIdInSubtree', 'isEnabled', 'isNotificationsPerMetricDimensionEnabled', 'isAllSuppressions']) {
1073+
for (const key of [
1074+
'compartmentIdInSubtree',
1075+
'metricCompartmentIdInSubtree',
1076+
'isEnabled',
1077+
'isNotificationsPerMetricDimensionEnabled',
1078+
'isAllSuppressions',
1079+
]) {
10651080
if (result[key] === 'true') result[key] = true
10661081
else if (result[key] === 'false') result[key] = false
10671082
}

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

Lines changed: 79 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ const metric = {
4141
}
4242
const cases = [
4343
['list_metrics', { compartmentId: 'compartment' }],
44-
['summarize_metrics_data', {
45-
compartmentId: 'compartment', namespace: 'my_app', query: 'Requests[1m].mean()',
46-
}],
44+
[
45+
'summarize_metrics_data',
46+
{
47+
compartmentId: 'compartment',
48+
namespace: 'my_app',
49+
query: 'Requests[1m].mean()',
50+
},
51+
],
4752
['post_metric_data', { metricData: [metric] }],
4853
['list_alarms', { compartmentId: 'compartment' }],
4954
['list_alarms_status', { compartmentId: 'compartment' }],
@@ -53,10 +58,15 @@ const cases = [
5358
['create_alarm', alarm],
5459
['update_alarm', { alarmId: 'alarm', isEnabled: false }],
5560
['delete_alarm', { alarmId: 'alarm' }],
56-
['create_alarm_suppression', {
57-
alarmId: 'alarm', displayName: 'Maintenance',
58-
timeSuppressFrom: '2026-09-05T12:00:00Z', timeSuppressUntil: '2026-09-05T13:00:00Z',
59-
}],
61+
[
62+
'create_alarm_suppression',
63+
{
64+
alarmId: 'alarm',
65+
displayName: 'Maintenance',
66+
timeSuppressFrom: '2026-09-05T12:00:00Z',
67+
timeSuppressUntil: '2026-09-05T13:00:00Z',
68+
},
69+
],
6070
['list_alarm_suppressions', { alarmId: 'alarm' }],
6171
['get_alarm_suppression', { alarmSuppressionId: 'suppression' }],
6272
['delete_alarm_suppression', { alarmSuppressionId: 'suppression' }],
@@ -71,7 +81,8 @@ function request(overrides: Partial<InternalToolOperationCall> = {}): InternalTo
7181
input: { ...connection, compartmentId: 'compartment' },
7282
headers: new Headers(),
7383
context: {
74-
userId: 'trusted-user', workspaceId: 'trusted-workspace',
84+
userId: 'trusted-user',
85+
workspaceId: 'trusted-workspace',
7586
workflowId: 'trusted-workflow',
7687
},
7788
requestId: 'request',
@@ -83,23 +94,30 @@ describe('OCI Monitoring internal dispatcher', () => {
8394
beforeEach(() => {
8495
vi.clearAllMocks()
8596
mocks.authorize.mockResolvedValue({
86-
ok: true, resolvedCredentialId: 'authorized-credential', credentialType: 'service_account',
97+
ok: true,
98+
resolvedCredentialId: 'authorized-credential',
99+
credentialType: 'service_account',
87100
})
88101
mocks.createClient.mockResolvedValue(client)
89102
mocks.execute.mockResolvedValue({ success: true, output: { opcRequestId: 'oracle-request' } })
90103
})
91104

92105
it.each(cases)('authorizes and dispatches %s with cancellation', async (operation, input) => {
93106
const controller = new AbortController()
94-
const response = await executeOciMonitoringTool(request({
95-
toolId: `oci_monitoring_${operation}`,
96-
input: { ...connection, ...input },
97-
signal: controller.signal,
98-
}))
107+
const response = await executeOciMonitoringTool(
108+
request({
109+
toolId: `oci_monitoring_${operation}`,
110+
input: { ...connection, ...input },
111+
signal: controller.signal,
112+
})
113+
)
99114

100115
expect(response.status).toBe(200)
101116
expect(mocks.execute).toHaveBeenCalledWith(
102-
client, operation, expect.objectContaining(input), controller.signal
117+
client,
118+
operation,
119+
expect.objectContaining(input),
120+
controller.signal
103121
)
104122
expect(mocks.createClient).toHaveBeenCalledWith({
105123
credentialId: 'authorized-credential',
@@ -110,17 +128,27 @@ describe('OCI Monitoring internal dispatcher', () => {
110128
})
111129

112130
it('uses execution identity and scope instead of forged input context', async () => {
113-
await executeOciMonitoringTool(request({
114-
input: { ...connection, compartmentId: 'compartment',
115-
userId: 'forged-user', workspaceId: 'forged-workspace', workflowId: 'forged-workflow',
116-
resolvedCredentialId: 'forged-credential', serviceId: 'oci_logging' },
117-
}))
131+
await executeOciMonitoringTool(
132+
request({
133+
input: {
134+
...connection,
135+
compartmentId: 'compartment',
136+
userId: 'forged-user',
137+
workspaceId: 'forged-workspace',
138+
workflowId: 'forged-workflow',
139+
resolvedCredentialId: 'forged-credential',
140+
serviceId: 'oci_logging',
141+
},
142+
})
143+
)
118144

119145
expect(mocks.authorize).toHaveBeenCalledWith(
120146
expect.objectContaining({ success: true, userId: 'trusted-user' }),
121147
{
122-
credentialId: 'requested-credential', workspaceId: 'trusted-workspace',
123-
workflowId: 'trusted-workflow', callerUserId: 'trusted-user',
148+
credentialId: 'requested-credential',
149+
workspaceId: 'trusted-workspace',
150+
workflowId: 'trusted-workflow',
151+
callerUserId: 'trusted-user',
124152
}
125153
)
126154
expect(mocks.execute.mock.calls[0][2]).not.toHaveProperty('workspaceId')
@@ -166,26 +194,39 @@ describe('OCI Monitoring internal dispatcher', () => {
166194

167195
it('preserves partial ingestion details and non-retryability', async () => {
168196
const failure = {
169-
success: false, retryable: false, error: 'Rejected metric',
170-
output: { failedMetricsCount: 1, failedMetrics: [{ message: 'invalid', metricData: metric }] },
197+
success: false,
198+
retryable: false,
199+
error: 'Rejected metric',
200+
output: {
201+
failedMetricsCount: 1,
202+
failedMetrics: [{ message: 'invalid', metricData: metric }],
203+
},
171204
}
172205
mocks.execute.mockResolvedValueOnce(failure)
173-
const response = await executeOciMonitoringTool(request({
174-
toolId: 'oci_monitoring_post_metric_data', input: { ...connection, metricData: [metric] },
175-
}))
206+
const response = await executeOciMonitoringTool(
207+
request({
208+
toolId: 'oci_monitoring_post_metric_data',
209+
input: { ...connection, metricData: [metric] },
210+
})
211+
)
176212
await expect(response.json()).resolves.toEqual(failure)
177213
})
178214

179215
it('marks ingestion transport failures non-retryable and retains the request ID', async () => {
180216
mocks.execute.mockRejectedValueOnce(
181217
new OciClientError('request_failed', { status: 503, opcRequestId: 'failed-request' })
182218
)
183-
const response = await executeOciMonitoringTool(request({
184-
toolId: 'oci_monitoring_post_metric_data', input: { ...connection, metricData: [metric] },
185-
}))
219+
const response = await executeOciMonitoringTool(
220+
request({
221+
toolId: 'oci_monitoring_post_metric_data',
222+
input: { ...connection, metricData: [metric] },
223+
})
224+
)
186225
expect(response.status).toBe(503)
187226
await expect(response.json()).resolves.toMatchObject({
188-
success: false, retryable: false, output: { opcRequestId: 'failed-request' },
227+
success: false,
228+
retryable: false,
229+
output: { opcRequestId: 'failed-request' },
189230
})
190231
})
191232

@@ -217,9 +258,13 @@ describe('OCI Monitoring internal dispatcher', () => {
217258
controller.abort()
218259
return { ok: true, credentialType: 'service_account', resolvedCredentialId: 'credential' }
219260
})
220-
await expect(executeOciMonitoringTool(request({
221-
signal: controller.signal,
222-
}))).rejects.toMatchObject({ name: 'AbortError' })
261+
await expect(
262+
executeOciMonitoringTool(
263+
request({
264+
signal: controller.signal,
265+
})
266+
)
267+
).rejects.toMatchObject({ name: 'AbortError' })
223268
expect(mocks.createClient).not.toHaveBeenCalled()
224269
})
225270
})

apps/sim/lib/internal/oci-monitoring/execute-tool.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export const executeOciMonitoringTool: InternalToolOperationHandler = async (req
2424
{ status: 400 }
2525
)
2626
}
27-
const parsed = ociMonitoringInputSchemas[operation as OciMonitoringOperation].safeParse(request.input)
27+
const parsed = ociMonitoringInputSchemas[operation as OciMonitoringOperation].safeParse(
28+
request.input
29+
)
2830
if (!parsed.success) {
2931
return Response.json(
3032
{
@@ -102,7 +104,7 @@ export const executeOciMonitoringTool: InternalToolOperationHandler = async (req
102104
? 403
103105
: error.code === 'invalid_request' || error.code === 'invalid_endpoint'
104106
? 400
105-
: error.status ?? 502
107+
: (error.status ?? 502)
106108
: 502
107109
return Response.json(
108110
{
@@ -113,7 +115,7 @@ export const executeOciMonitoringTool: InternalToolOperationHandler = async (req
113115
? error.message
114116
: 'OCI Monitoring request failed',
115117
output: {
116-
opcRequestId: error instanceof OciClientError ? error.opcRequestId ?? null : null,
118+
opcRequestId: error instanceof OciClientError ? (error.opcRequestId ?? null) : null,
117119
},
118120
},
119121
{ status }

apps/sim/lib/internal/oci-monitoring/input.ts

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,17 @@ const alarmFields = {
7070
isEnabled: z.boolean(),
7171
...tags,
7272
overrides: json(
73-
z.array(
74-
z.object({
75-
ruleName: z.string().min(1).max(64).optional(),
76-
query: text.optional(),
77-
severity: severity.optional(),
78-
pendingDuration: z.string().min(1).max(64).optional(),
79-
body: z.string().max(4000).optional(),
80-
})
81-
).max(2)
73+
z
74+
.array(
75+
z.object({
76+
ruleName: z.string().min(1).max(64).optional(),
77+
query: text.optional(),
78+
severity: severity.optional(),
79+
pendingDuration: z.string().min(1).max(64).optional(),
80+
body: z.string().max(4000).optional(),
81+
})
82+
)
83+
.max(2)
8284
).optional(),
8385
ruleName: z.string().min(1).max(64).optional(),
8486
notificationVersion: z.string().min(1).max(64).optional(),
@@ -88,7 +90,11 @@ const alarmFields = {
8890
}
8991
const metricDimensions = z
9092
.record(
91-
z.string().min(1).max(256).regex(/^[\x21-\x7e]+$/),
93+
z
94+
.string()
95+
.min(1)
96+
.max(256)
97+
.regex(/^[\x21-\x7e]+$/),
9298
z.string().min(1).max(512)
9399
)
94100
.refine((value) => Object.keys(value).length >= 1 && Object.keys(value).length <= 20, {
@@ -104,7 +110,10 @@ const metric = z.object({
104110
'Custom namespaces cannot use the oci_ or oracle_ prefixes'
105111
),
106112
name: z.string().regex(/^[A-Za-z][A-Za-z0-9._$-]*$/),
107-
resourceGroup: z.string().regex(/^[A-Za-z][A-Za-z0-9._$-]*$/).optional(),
113+
resourceGroup: z
114+
.string()
115+
.regex(/^[A-Za-z][A-Za-z0-9._$-]*$/)
116+
.optional(),
108117
dimensions: metricDimensions,
109118
metadata: z.record(z.string().min(1).max(256), z.string().max(256)).optional(),
110119
datapoints: z
@@ -129,7 +138,12 @@ export const ociMonitoringInputSchemas = {
129138
namespace: text.optional(),
130139
resourceGroup: text.nullable().optional(),
131140
dimensionFilters: json(strings).optional(),
132-
groupBy: json(z.array(z.enum(['namespace', 'name', 'resourceGroup'])).min(1).max(3)).optional(),
141+
groupBy: json(
142+
z
143+
.array(z.enum(['namespace', 'name', 'resourceGroup']))
144+
.min(1)
145+
.max(3)
146+
).optional(),
133147
sortBy: z.enum(['NAMESPACE', 'NAME', 'RESOURCEGROUP']).optional(),
134148
}),
135149
summarize_metrics_data: z
@@ -150,7 +164,9 @@ export const ociMonitoringInputSchemas = {
150164
})
151165
.refine(
152166
(value) =>
153-
!value.startTime || !value.endTime || Date.parse(value.startTime) < Date.parse(value.endTime),
167+
!value.startTime ||
168+
!value.endTime ||
169+
Date.parse(value.startTime) < Date.parse(value.endTime),
154170
{ message: 'Start time must precede end time', path: ['endTime'] }
155171
),
156172
post_metric_data: z.object({
@@ -185,7 +201,12 @@ export const ociMonitoringInputSchemas = {
185201
...alarmId,
186202
...page,
187203
alarmHistorytype: z
188-
.enum(['STATE_HISTORY', 'STATE_TRANSITION_HISTORY', 'RULE_HISTORY', 'RULE_TRANSITION_HISTORY'])
204+
.enum([
205+
'STATE_HISTORY',
206+
'STATE_TRANSITION_HISTORY',
207+
'RULE_HISTORY',
208+
'RULE_TRANSITION_HISTORY',
209+
])
189210
.optional(),
190211
timestampGreaterThanOrEqualTo: timestamp.optional(),
191212
timestampLessThan: timestamp.optional(),
@@ -226,7 +247,10 @@ export const ociMonitoringInputSchemas = {
226247
path: ['timeSuppressUntil'],
227248
})
228249
}
229-
if (value.level === 'DIMENSION' && (!value.dimensions || !Object.keys(value.dimensions).length)) {
250+
if (
251+
value.level === 'DIMENSION' &&
252+
(!value.dimensions || !Object.keys(value.dimensions).length)
253+
) {
230254
context.addIssue({
231255
code: z.ZodIssueCode.custom,
232256
message: 'Dimension suppression requires nonempty dimensions',
@@ -266,9 +290,7 @@ export const ociMonitoringInputSchemas = {
266290
} as const
267291

268292
export type OciMonitoringOperation = keyof typeof ociMonitoringInputSchemas
269-
export type OciMonitoringInput<K extends OciMonitoringOperation = OciMonitoringOperation> = z.output<
270-
(typeof ociMonitoringInputSchemas)[K]
271-
>
272-
export type OciMonitoringParams<K extends OciMonitoringOperation = OciMonitoringOperation> = z.input<
273-
(typeof ociMonitoringInputSchemas)[K]
274-
>
293+
export type OciMonitoringInput<K extends OciMonitoringOperation = OciMonitoringOperation> =
294+
z.output<(typeof ociMonitoringInputSchemas)[K]>
295+
export type OciMonitoringParams<K extends OciMonitoringOperation = OciMonitoringOperation> =
296+
z.input<(typeof ociMonitoringInputSchemas)[K]>

0 commit comments

Comments
 (0)