Skip to content

Commit 2894d57

Browse files
waleedlatif1claude
andcommitted
fix(tinyfish): reject a malformed numeric cap instead of dropping it
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ej1gsFPVzN5xZZ3QzvK8bD
1 parent 01c3cc6 commit 2894d57

2 files changed

Lines changed: 46 additions & 5 deletions

File tree

apps/sim/blocks/blocks/tinyfish.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,30 @@ Return ONLY the comma-separated URL list - no explanations, no extra text.`,
501501
params: (params) => {
502502
const result: Record<string, unknown> = {}
503503

504+
/**
505+
* A numeric text input that does not parse is rejected rather than
506+
* dropped. Omitting it silently hands the run TinyFish's default — no
507+
* wall-clock limit at all for Max Duration — while the block still
508+
* shows the value the user typed.
509+
*/
510+
const toFiniteNumber = (value: string, field: string): number => {
511+
const parsed = Number(value)
512+
if (!Number.isFinite(parsed)) {
513+
throw new Error(`Invalid numeric value for ${field}: ${value}`)
514+
}
515+
return parsed
516+
}
517+
504518
const maxSteps = String(params.maxSteps ?? '').trim()
505-
if (maxSteps) result.maxSteps = Number(maxSteps)
519+
if (maxSteps) result.maxSteps = toFiniteNumber(maxSteps, 'Max Steps')
506520

507521
const maxDurationSeconds = String(params.maxDurationSeconds ?? '').trim()
508-
if (maxDurationSeconds) result.maxDurationSeconds = Number(maxDurationSeconds)
522+
if (maxDurationSeconds) {
523+
result.maxDurationSeconds = toFiniteNumber(maxDurationSeconds, 'Max Duration (seconds)')
524+
}
509525

510526
const limit = String(params.limit ?? '').trim()
511-
if (limit) result.limit = Number(limit)
527+
if (limit) result.limit = toFiniteNumber(limit, 'Limit')
512528

513529
/**
514530
* The list filter has its own sub-block id so it does not collide with
@@ -594,7 +610,7 @@ Return ONLY the comma-separated URL list - no explanations, no extra text.`,
594610
runs: {
595611
type: 'json',
596612
description:
597-
'Runs matching the list filters [{runId, status, goal, createdAt, startedAt, finishedAt, numOfSteps, result, schemaValidation, error, streamingUrl, browserConfig}]',
613+
'Runs matching the list filters [{runId, status, goal, createdAt, startedAt, finishedAt, numOfSteps, result, schemaValidation, error, streamingUrl, browserConfig, profileAttached, profileId, profileHint}]',
598614
},
599615
total: { type: 'number', description: 'Total runs matching the list filters' },
600616
nextCursor: { type: 'string', description: 'Cursor for the next page of runs' },
@@ -628,7 +644,7 @@ Return ONLY the comma-separated URL list - no explanations, no extra text.`,
628644
profiles: {
629645
type: 'json',
630646
description:
631-
'Browser Context Profiles a run can start from [{profileId, name, proxyCountryCode, fingerprintSeed, createdAt, isDefault}]. Every field but profileId and name can be null when the API omits it',
647+
'Browser Context Profiles a run can start from [{profileId, name, proxyCountryCode, fingerprintSeed, domainCount, createdAt, updatedAt, isDefault}]. Every field but profileId and name can be null when the API omits it',
632648
},
633649
},
634650
}

apps/sim/tools/tinyfish/tinyfish.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,31 @@ describe('TinyFish block', () => {
820820
expect(params).not.toHaveProperty('goal')
821821
})
822822

823+
it('rejects a numeric text input that does not parse instead of dropping the cap', () => {
824+
expect(() =>
825+
TinyFishBlock.tools.config?.params?.({
826+
operation: 'tinyfish_run',
827+
maxDurationSeconds: '5 minutes',
828+
})
829+
).toThrow('Invalid numeric value for Max Duration (seconds): 5 minutes')
830+
831+
expect(() =>
832+
TinyFishBlock.tools.config?.params?.({ operation: 'tinyfish_run', maxSteps: 'lots' })
833+
).toThrow('Invalid numeric value for Max Steps: lots')
834+
})
835+
836+
it('coerces the duration cap and drops it when blank', () => {
837+
expect(
838+
TinyFishBlock.tools.config?.params?.({
839+
operation: 'tinyfish_run',
840+
maxDurationSeconds: '300',
841+
})
842+
).toMatchObject({ maxDurationSeconds: 300 })
843+
expect(
844+
TinyFishBlock.tools.config?.params?.({ operation: 'tinyfish_run', maxDurationSeconds: ' ' })
845+
).not.toHaveProperty('maxDurationSeconds')
846+
})
847+
823848
it('coerces the numeric text inputs and drops them when blank', () => {
824849
expect(
825850
TinyFishBlock.tools.config?.params?.({ operation: 'tinyfish_run', maxSteps: '50' })

0 commit comments

Comments
 (0)