Skip to content

Commit 4355f7d

Browse files
committed
fix(integrations): validate cloudtrail, codepipeline, sqs and ssm
1 parent 0be28a0 commit 4355f7d

8 files changed

Lines changed: 103 additions & 39 deletions

File tree

‎apps/docs/content/docs/integrations/cloudtrail.mdx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,14 @@ List the CloudTrail Lake event data stores in the account for the current Region
425425
| `eventDataStores` | array | Event data stores in the account for the current Region |
426426
| ↳ `eventDataStoreArn` | string | ARN of the event data store |
427427
| ↳ `name` | string | Name of the event data store |
428-
| ↳ `status` | string | CREATED, ENABLED, PENDING_DELETION, or an ingestion state |
429-
| ↳ `advancedEventSelectors` | array | Advanced event selectors that define what the store ingests |
430-
| ↳ `multiRegionEnabled` | boolean | Whether the store collects events from all Regions |
431-
| ↳ `organizationEnabled` | boolean | Whether the store collects events for the organization |
432-
| ↳ `retentionPeriod` | number | Retention period in days |
433-
| ↳ `terminationProtectionEnabled` | boolean | Whether termination protection is enabled |
434-
| ↳ `createdTimestamp` | string | When the store was created \(ISO 8601\) |
435-
| ↳ `updatedTimestamp` | string | When the store was last updated \(ISO 8601\) |
428+
| ↳ `status` | string | Store status. AWS no longer returns it from this list; read it with Get Event Data Store |
429+
| ↳ `advancedEventSelectors` | array | Advanced event selectors. AWS no longer returns it from this list; read it with Get Event Data Store |
430+
| ↳ `multiRegionEnabled` | boolean | Whether the store is multi-Region. AWS no longer returns it from this list; read it with Get Event Data Store |
431+
| ↳ `organizationEnabled` | boolean | Whether the store is an organization store. AWS no longer returns it from this list; read it with Get Event Data Store |
432+
| ↳ `retentionPeriod` | number | Retention period in days. AWS no longer returns it from this list; read it with Get Event Data Store |
433+
| ↳ `terminationProtectionEnabled` | boolean | Whether termination protection is enabled. AWS no longer returns it from this list; read it with Get Event Data Store |
434+
| ↳ `createdTimestamp` | string | Creation time. AWS no longer returns it from this list; read it with Get Event Data Store |
435+
| ↳ `updatedTimestamp` | string | Last update time. AWS no longer returns it from this list; read it with Get Event Data Store |
436436
| `nextToken` | string | Pagination token for the next page of event data stores |
437437

438438
</ReferenceDetails>

‎apps/sim/blocks/blocks/aws-stale-inputs.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@ import { awsDynamodbScanContract } from '@/lib/api/contracts/tools/aws/dynamodb-
99
import { awsIamCreateUserContract } from '@/lib/api/contracts/tools/aws/iam-create-user'
1010
import { awsIamListPoliciesContract } from '@/lib/api/contracts/tools/aws/iam-list-policies'
1111
import { awsSesSendTemplatedEmailContract } from '@/lib/api/contracts/tools/aws/ses-send-templated-email'
12+
import { awsSqsListMessageMoveTasksContract } from '@/lib/api/contracts/tools/aws/sqs-list-message-move-tasks'
13+
import { awsSsmGetParametersByPathContract } from '@/lib/api/contracts/tools/aws/ssm-get-parameters-by-path'
1214
import { CloudFormationBlock } from '@/blocks/blocks/cloudformation'
1315
import { DynamoDBBlock } from '@/blocks/blocks/dynamodb'
1416
import { IAMBlock } from '@/blocks/blocks/iam'
1517
import { SESBlock } from '@/blocks/blocks/ses'
18+
import { SQSBlock } from '@/blocks/blocks/sqs'
19+
import { SSMBlock } from '@/blocks/blocks/ssm'
1620
import type { BlockConfig } from '@/blocks/types'
1721
import { createChangeSetTool } from '@/tools/cloudformation/create_change_set'
1822
import { scanTool } from '@/tools/dynamodb/scan'
1923
import { createUserTool } from '@/tools/iam/create_user'
2024
import { listPoliciesTool } from '@/tools/iam/list_policies'
2125
import { sendTemplatedEmailTool } from '@/tools/ses/send_templated_email'
26+
import { listMessageMoveTasksTool } from '@/tools/sqs/list_message_move_tasks'
27+
import { receiveMessageTool } from '@/tools/sqs/receive_message'
28+
import { getParametersByPathTool } from '@/tools/ssm/get_parameters_by_path'
2229

2330
const AWS = { region: 'us-east-1', accessKeyId: 'AKIAEXAMPLE', secretAccessKey: 'secret' }
2431

@@ -104,4 +111,42 @@ describe('AWS blocks keep stale subBlock values out of tool input', () => {
104111
})
105112
).toThrow('Tags must be a list of {"key", "value"} entries or a JSON object')
106113
})
114+
115+
it('SQS receive ignores the change-visibility timeout', () => {
116+
const params = executorParams(SQSBlock, {
117+
...AWS,
118+
operation: 'receive_message',
119+
queueUrl: 'https://sqs.us-east-1.amazonaws.com/123456789012/orders',
120+
visibilityTimeout: '43200',
121+
})
122+
const body = receiveMessageTool.operation.input(params as never) as Record<string, unknown>
123+
expect(body.visibilityTimeout).toBeUndefined()
124+
})
125+
126+
it('SQS list move tasks ignores the list queues max results', () => {
127+
const params = executorParams(SQSBlock, {
128+
...AWS,
129+
operation: 'list_message_move_tasks',
130+
sourceArn: 'arn:aws:sqs:us-east-1:123456789012:orders-dlq',
131+
maxResults: '1000',
132+
})
133+
const body = listMessageMoveTasksTool.operation.input(params as never) as Record<
134+
string,
135+
unknown
136+
>
137+
expect(body.maxResults).toBeUndefined()
138+
expect(awsSqsListMessageMoveTasksContract.body?.safeParse(body).success).toBe(true)
139+
})
140+
141+
it('SSM get parameters by path ignores the list max results', () => {
142+
const params = executorParams(SSMBlock, {
143+
...AWS,
144+
operation: 'get_parameters_by_path',
145+
parameterPath: '/app',
146+
maxResults: '50',
147+
})
148+
const body = getParametersByPathTool.operation.input(params as never) as Record<string, unknown>
149+
expect(body.maxResults).toBeUndefined()
150+
expect(awsSsmGetParametersByPathContract.body?.safeParse(body).success).toBe(true)
151+
})
107152
})

‎apps/sim/blocks/blocks/cloudtrail.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ export const CloudTrailBlockMeta = {
862862
description:
863863
'Run a SQL query against a CloudTrail Lake event data store, wait for it to finish, and return the rows. Use for aggregate audit questions that span more than 90 days.',
864864
content:
865-
'# Run Lake Query\n\nAnswer an aggregate audit question with CloudTrail Lake.\n\n## Steps\n1. List event data stores, or get one by ARN, to find the store ID to query and confirm its retention period.\n2. Compose the SQL, naming the event data store ID in the FROM clause.\n3. Start the query to obtain a query ID.\n4. Poll describe query with that query ID until the status is FINISHED, FAILED, CANCELLED, or TIMED_OUT.\n5. On FINISHED, fetch the query results with the same query ID, paging with the returned token until no token comes back.\n6. Cancel the query if it is no longer needed while still RUNNING.\n\n## Output\nThe result rows, plus the query ID, events matched, events scanned, and run time. On failure, surface the error message and the SQL that produced it.',
865+
'# Run Lake Query\n\nAnswer an aggregate audit question with CloudTrail Lake.\n\n## Steps\n1. List event data stores to find the store to query, then get it by ARN to confirm its status and retention period.\n2. Compose the SQL, naming the event data store ID in the FROM clause.\n3. Start the query to obtain a query ID.\n4. Poll describe query with that query ID until the status is FINISHED, FAILED, CANCELLED, or TIMED_OUT.\n5. On FINISHED, fetch the query results with the same query ID, paging with the returned token until no token comes back.\n6. Cancel the query if it is no longer needed while still RUNNING.\n\n## Output\nThe result rows, plus the query ID, events matched, events scanned, and run time. On failure, surface the error message and the SQL that produced it.',
866866
},
867867
],
868868
} as const satisfies BlockMeta

‎apps/sim/blocks/blocks/codepipeline.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,22 @@ export const CodePipelineBlock: BlockConfig = {
411411
const awsRegion = rest.awsRegion
412412
const awsAccessKeyId = rest.awsAccessKeyId
413413
const awsSecretAccessKey = rest.awsSecretAccessKey
414-
const parsedMaxResults = parseOptionalNumberInput(maxResults, 'Max results', {
415-
integer: true,
416-
min: 1,
417-
})
414+
/** Parsed only by the list operations, so a value left in the hidden field never fails another one. */
415+
const maxResultsParam = () => {
416+
const parsed = parseOptionalNumberInput(maxResults, 'Max results', {
417+
integer: true,
418+
min: 1,
419+
})
420+
return parsed === undefined ? {} : { maxResults: parsed }
421+
}
418422

419423
switch (operation) {
420424
case 'list_pipelines':
421425
return {
422426
awsRegion,
423427
awsAccessKeyId,
424428
awsSecretAccessKey,
425-
...(parsedMaxResults !== undefined && { maxResults: parsedMaxResults }),
429+
...maxResultsParam(),
426430
...(rest.nextToken && { nextToken: rest.nextToken }),
427431
}
428432

@@ -463,7 +467,7 @@ export const CodePipelineBlock: BlockConfig = {
463467
awsAccessKeyId,
464468
awsSecretAccessKey,
465469
pipelineName: rest.pipelineName,
466-
...(parsedMaxResults !== undefined && { maxResults: parsedMaxResults }),
470+
...maxResultsParam(),
467471
...(rest.nextToken && { nextToken: rest.nextToken }),
468472
...(rest.succeededInStage && { succeededInStage: rest.succeededInStage }),
469473
}
@@ -475,7 +479,7 @@ export const CodePipelineBlock: BlockConfig = {
475479
awsSecretAccessKey,
476480
pipelineName: rest.pipelineName,
477481
...(rest.pipelineExecutionId && { pipelineExecutionId: rest.pipelineExecutionId }),
478-
...(parsedMaxResults !== undefined && { maxResults: parsedMaxResults }),
482+
...maxResultsParam(),
479483
...(rest.nextToken && { nextToken: rest.nextToken }),
480484
}
481485

‎apps/sim/blocks/blocks/sqs.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getErrorMessage } from '@sim/utils/errors'
22
import { SQSIcon } from '@/components/icons'
33
import type { BlockConfig, BlockMeta } from '@/blocks/types'
44
import { AuthMode, IntegrationType } from '@/blocks/types'
5-
import { mapperOperation, withSavedCredential } from '@/blocks/utils'
5+
import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils'
66

77
export const SQSBlock: BlockConfig = {
88
type: 'sqs',
@@ -672,11 +672,10 @@ export const SQSBlock: BlockConfig = {
672672
if (maxNumberOfMessages !== undefined) result.maxNumberOfMessages = maxNumberOfMessages
673673
const waitTimeSeconds = parseInteger(params.waitTimeSeconds, 'waitTimeSeconds')
674674
if (waitTimeSeconds !== undefined) result.waitTimeSeconds = waitTimeSeconds
675-
const visibilityTimeout = parseInteger(
676-
params.receiveVisibilityTimeout,
675+
result.visibilityTimeout = parseInteger(
676+
params.receiveVisibilityTimeout ?? toolCallArg(context, params.visibilityTimeout),
677677
'visibilityTimeout'
678678
)
679-
if (visibilityTimeout !== undefined) result.visibilityTimeout = visibilityTimeout
680679
const messageAttributeNames = parseJson(
681680
params.messageAttributeNames,
682681
'messageAttributeNames'
@@ -791,8 +790,10 @@ export const SQSBlock: BlockConfig = {
791790
}
792791
case 'list_message_move_tasks': {
793792
result.sourceArn = params.sourceArn
794-
const maxResults = parseInteger(params.moveTaskMaxResults, 'maxResults')
795-
if (maxResults !== undefined) result.maxResults = maxResults
793+
result.maxResults = parseInteger(
794+
params.moveTaskMaxResults ?? toolCallArg(context, params.maxResults),
795+
'maxResults'
796+
)
796797
break
797798
}
798799
case 'cancel_message_move_task': {

‎apps/sim/blocks/blocks/ssm.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,7 @@ export const SSMBlock: BlockConfig = {
874874
setBoolean('recursive', params.recursive)
875875
setBoolean('withDecryption', params.withDecryption)
876876
setJson('parameterFilters', params.parameterFilters)
877-
setNumber(
878-
'maxResults',
877+
result.maxResults = toOptionalNumber(
879878
params.pathMaxResults ?? toolCallArg(context, params.maxResults)
880879
)
881880
setString('nextToken', params.nextToken)
@@ -906,25 +905,22 @@ export const SSMBlock: BlockConfig = {
906905
break
907906
case 'describe_instance_information':
908907
setJson('filters', params.instanceInfoFilters ?? toolCallArg(context, params.filters))
909-
setNumber(
910-
'maxResults',
908+
result.maxResults = toOptionalNumber(
911909
params.instanceInfoMaxResults ?? toolCallArg(context, params.maxResults)
912910
)
913911
setString('nextToken', params.nextToken)
914912
break
915913
case 'describe_instance_patches':
916914
result.instanceId = params.instanceId
917915
setJson('filters', params.patchFilters ?? toolCallArg(context, params.filters))
918-
setNumber(
919-
'maxResults',
916+
result.maxResults = toOptionalNumber(
920917
params.patchMaxResults ?? toolCallArg(context, params.maxResults)
921918
)
922919
setString('nextToken', params.nextToken)
923920
break
924921
case 'describe_instance_patch_states':
925922
setJson('instanceIds', params.instanceIds)
926-
setNumber(
927-
'maxResults',
923+
result.maxResults = toOptionalNumber(
928924
params.patchMaxResults ?? toolCallArg(context, params.maxResults)
929925
)
930926
setString('nextToken', params.nextToken)

‎apps/sim/tools/cloudtrail/list_event_data_stores.ts‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,32 +83,50 @@ export const listEventDataStoresTool: InternalToolConfig<
8383
name: { type: 'string', description: 'Name of the event data store' },
8484
status: {
8585
type: 'string',
86-
description: 'CREATED, ENABLED, PENDING_DELETION, or an ingestion state',
86+
description:
87+
'Store status. AWS no longer returns it from this list; read it with Get Event Data Store',
88+
optional: true,
8789
},
8890
advancedEventSelectors: {
8991
type: 'array',
90-
description: 'Advanced event selectors that define what the store ingests',
92+
description:
93+
'Advanced event selectors. AWS no longer returns it from this list; read it with Get Event Data Store',
9194
},
9295
multiRegionEnabled: {
9396
type: 'boolean',
94-
description: 'Whether the store collects events from all Regions',
97+
description:
98+
'Whether the store is multi-Region. AWS no longer returns it from this list; read it with Get Event Data Store',
99+
optional: true,
95100
},
96101
organizationEnabled: {
97102
type: 'boolean',
98-
description: 'Whether the store collects events for the organization',
103+
description:
104+
'Whether the store is an organization store. AWS no longer returns it from this list; read it with Get Event Data Store',
105+
optional: true,
106+
},
107+
retentionPeriod: {
108+
type: 'number',
109+
description:
110+
'Retention period in days. AWS no longer returns it from this list; read it with Get Event Data Store',
111+
optional: true,
99112
},
100-
retentionPeriod: { type: 'number', description: 'Retention period in days' },
101113
terminationProtectionEnabled: {
102114
type: 'boolean',
103-
description: 'Whether termination protection is enabled',
115+
description:
116+
'Whether termination protection is enabled. AWS no longer returns it from this list; read it with Get Event Data Store',
117+
optional: true,
104118
},
105119
createdTimestamp: {
106120
type: 'string',
107-
description: 'When the store was created (ISO 8601)',
121+
description:
122+
'Creation time. AWS no longer returns it from this list; read it with Get Event Data Store',
123+
optional: true,
108124
},
109125
updatedTimestamp: {
110126
type: 'string',
111-
description: 'When the store was last updated (ISO 8601)',
127+
description:
128+
'Last update time. AWS no longer returns it from this list; read it with Get Event Data Store',
129+
optional: true,
112130
},
113131
},
114132
},

‎apps/sim/tools/generated/tool-outputs.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)