Skip to content

Commit 9cb862d

Browse files
myxamediyarclaude
andcommitted
fix(video): reject a reference file that is not an image before submitting
An agent can pass any file as the start frame or Runway reference, and nothing checked its type before the paid request. Validation now returns a 400 for a non-image `visualReference` before the file is downloaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0dbb2a6 commit 9cb862d

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎apps/sim/lib/internal/video/client.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,32 @@ describe('Video provider client', () => {
513513
)
514514
})
515515

516+
it.each([
517+
{ provider: 'falai' as const, model: 'kling-v3-pro' },
518+
{ provider: 'runway' as const, model: 'gen4_turbo' },
519+
])(
520+
'rejects a non-image reference file for $provider before submitting',
521+
({ provider, model }) => {
522+
const pdf = {
523+
id: 'f',
524+
name: 'brief.pdf',
525+
url: '',
526+
size: 3,
527+
type: 'application/pdf',
528+
key: 'k',
529+
}
530+
expect(
531+
getVideoInputValidationError({
532+
provider,
533+
apiKey: 'key',
534+
model,
535+
prompt: 'Pan left',
536+
visualReference: pdf,
537+
})
538+
).toBe('Reference image must be an image file, not application/pdf')
539+
}
540+
)
541+
516542
it('rejects a start frame for a fal model without an image-to-video endpoint', () => {
517543
const frame = { id: 'f', name: 'frame.png', url: '', size: 3, type: 'image/png', key: 'k' }
518544
expect(

‎apps/sim/lib/internal/video/client.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ async function waitForProvider(context: VideoGenerationContext): Promise<void> {
9494
}
9595

9696
export function getVideoInputValidationError(input: VideoGenerationInput): string | undefined {
97+
if (input.visualReference && !input.visualReference.type.toLowerCase().startsWith('image/'))
98+
return `Reference image must be an image file, not ${input.visualReference.type || 'an unknown type'}`
9799
if (input.provider === 'falai') {
98100
if (input.prompt.length < 3 || input.prompt.length > 2000)
99101
return 'Prompt must be between 3 and 2000 characters'

0 commit comments

Comments
 (0)