Skip to content

Commit fba3435

Browse files
committed
fix(athena): keep zero-minute result reuse age, enforce name patterns, declare table parameters output
Claude-Session: https://claude.ai/code/session_01AtPwvDwhkhed2MwcZudrPN
1 parent 07650f9 commit fba3435

6 files changed

Lines changed: 37 additions & 6 deletions

File tree

apps/docs/content/docs/integrations/athena.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ List tables and their column/partition metadata for an Athena database
323323

324324
| Parameter | Type | Description |
325325
| --------- | ---- | ----------- |
326-
| `tables` | array | Table metadata \(name, type, columns, partition keys\) |
326+
| `tables` | array | Table metadata \(name, type, columns, partition keys, parameters\) |
327327
|`name` | string | Table name |
328328
|`tableType` | string | Table type |
329329
|`createTime` | number | Table creation time \(Unix epoch ms\) |
@@ -336,6 +336,7 @@ List tables and their column/partition metadata for an Athena database
336336
|`name` | string | Partition key name |
337337
|`type` | string | Partition key data type |
338338
|`comment` | string | Partition key comment |
339+
|`parameters` | json | Key/value table properties \(e.g., classification, location\) |
339340
| `nextToken` | string | Pagination token for next page |
340341

341342
### Athena Get Query Runtime Statistics

apps/sim/blocks/blocks/athena.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,12 @@ Return ONLY a JSON array of strings — no explanations, no markdown code blocks
702702
const parsedMaxResults = maxResults ? Number.parseInt(String(maxResults), 10) : undefined
703703
const connection = { awsRegion, awsAccessKeyId, awsSecretAccessKey }
704704
const resultReuseEnabled = parseBoolean(rest.resultReuseEnabled)
705-
const resultReuseMaxAgeInMinutes = rest.resultReuseMaxAgeInMinutes
706-
? Number.parseInt(String(rest.resultReuseMaxAgeInMinutes), 10)
707-
: undefined
705+
const resultReuseMaxAgeInMinutes =
706+
rest.resultReuseMaxAgeInMinutes !== undefined &&
707+
rest.resultReuseMaxAgeInMinutes !== null &&
708+
rest.resultReuseMaxAgeInMinutes !== ''
709+
? Number.parseInt(String(rest.resultReuseMaxAgeInMinutes), 10)
710+
: undefined
708711

709712
switch (operation) {
710713
case 'start_query':

apps/sim/lib/api/contracts/tools/aws/athena-shared.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const athenaWorkGroupSchema = z
2323
.trim()
2424
.min(1, 'Workgroup is required')
2525
.max(128, 'Workgroup must be at most 128 characters')
26+
.regex(/^[a-zA-Z0-9._-]+$/, 'Workgroup may only contain letters, digits, ".", "_", and "-"')
2627

2728
/**
2829
* Optional workgroup; blank strings from unfilled inputs are treated as omitted.
@@ -40,6 +41,10 @@ export const athenaStatementNameSchema = z
4041
.trim()
4142
.min(1, 'Statement name is required')
4243
.max(256, 'Statement name must be at most 256 characters')
44+
.regex(
45+
/^[a-zA-Z_][a-zA-Z0-9_@:]+$/,
46+
'Statement name must start with a letter or underscore and contain only letters, digits, "_", "@", and ":"'
47+
)
4348

4449
/**
4550
* Builds the optional `maxResults` field with Athena's documented bounds for the operation.

apps/sim/lib/internal/athena/execute-tool.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,24 @@ describe('executeAthenaTool', () => {
226226
)
227227
expect(missingWorkGroup.status).toBe(400)
228228
expect(mockOperations.executeAthenaListPreparedStatements).not.toHaveBeenCalled()
229+
230+
const badStatementName = await executeAthenaTool(
231+
createRequest({
232+
toolId: 'athena_get_prepared_statement',
233+
input: { ...PREPARED_WORKGROUP, statementName: '1-bad name' },
234+
})
235+
)
236+
expect(badStatementName.status).toBe(400)
237+
expect(mockOperations.executeAthenaGetPreparedStatement).not.toHaveBeenCalled()
238+
239+
const badWorkGroup = await executeAthenaTool(
240+
createRequest({
241+
toolId: 'athena_get_work_group',
242+
input: { ...CONNECTION, workGroup: 'my wg' },
243+
})
244+
)
245+
expect(badWorkGroup.status).toBe(400)
246+
expect(mockOperations.executeAthenaGetWorkGroup).not.toHaveBeenCalled()
229247
})
230248

231249
it('preserves the provider error envelope', async () => {

apps/sim/tools/athena/list_table_metadata.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const listTableMetadataTool: InternalToolConfig<
102102
outputs: {
103103
tables: {
104104
type: 'array',
105-
description: 'Table metadata (name, type, columns, partition keys)',
105+
description: 'Table metadata (name, type, columns, partition keys, parameters)',
106106
items: {
107107
type: 'object',
108108
properties: {
@@ -142,6 +142,10 @@ export const listTableMetadataTool: InternalToolConfig<
142142
},
143143
},
144144
},
145+
parameters: {
146+
type: 'json',
147+
description: 'Key/value table properties (e.g., classification, location)',
148+
},
145149
},
146150
},
147151
},

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)