Skip to content

Commit 9f2469d

Browse files
committed
fix(logs-block): declare the triggers input as the string it becomes
The generic handler JSON.parses any post-transform input declared 'array' or 'json'. Since `joinIds` has already turned the selection into a comma-separated string by then, the array declaration logged a parse warning on every run, and JSON-looking advanced input would have been turned into an array the tool does not accept. Matches the legacy Logs block, which already declares triggers as a string, and locks the invariant with a test. Also drops `any` from the new test helper.
1 parent 92264bf commit 9f2469d

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

apps/sim/blocks/blocks/logs.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ vi.mock('@/lib/workflows/subblocks/options', () => ({
1010

1111
import { LogsV2Block } from '@/blocks/blocks/logs'
1212

13-
function buildQueryParams(params: Record<string, any>) {
13+
function buildQueryParams(params: Record<string, unknown>) {
1414
return LogsV2Block.tools.config!.params!({ operation: 'query', ...params })
1515
}
1616

@@ -49,6 +49,14 @@ describe('LogsV2Block trigger filter', () => {
4949
describe('LogsV2Block trigger subblocks', () => {
5050
const subBlockIds = LogsV2Block.subBlocks.map((subBlock) => subBlock.id)
5151

52+
it('declares triggers as the string it is transformed into', () => {
53+
// The generic handler JSON.parses any post-transform input declared 'array' or
54+
// 'json', so declaring the joined string as an array would warn on every run
55+
// and would turn JSON-looking advanced input into an array the tool rejects.
56+
expect(LogsV2Block.inputs.triggers.type).toBe('string')
57+
expect(typeof buildQueryParams({ triggers: ['api', 'schedule'] }).triggers).toBe('string')
58+
})
59+
5260
it('exposes basic and advanced modes behind one canonical param', () => {
5361
expect(subBlockIds).toContain('triggerSelector')
5462
expect(subBlockIds).toContain('manualTriggers')

apps/sim/blocks/blocks/logs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ export const LogsV2Block: BlockConfig = {
597597
workflowIds: { type: 'array', description: 'Workflow IDs to filter by (canonical param)' },
598598
level: { type: 'array', description: 'Statuses to include (empty for all)' },
599599
triggers: {
600-
type: 'array',
601-
description: 'Trigger types to include (canonical param, empty for all)',
600+
type: 'string',
601+
description: 'Comma-separated trigger types to include (canonical param, empty for all)',
602602
},
603603
timeRange: { type: 'string', description: 'Preset time window' },
604604
startDate: { type: 'string', description: 'ISO 8601 lower bound (overrides Time Range)' },

0 commit comments

Comments
 (0)