Skip to content

Conversation

@anton-abyzov
Copy link

@anton-abyzov anton-abyzov commented Oct 20, 2025

Fixes #1033

Problem

Video files with uppercase extensions (e.g., .MP4) from AI video generation tools like OpenAI Sora are not being properly recognized as video files. Instead, they're being incorrectly processed by the Next.js Image component, resulting in 400 Bad Request errors in the Media Library.

Screenshot showing the error:
image

Root Cause

The application only checks for lowercase 'mp4' in file extensions:

media.path.indexOf('mp4') > -1

This fails for files with .MP4, .Mp4, or any other case variations.

Solution

Made all MP4 file detection case-insensitive by converting paths to lowercase before checking:

media.path.toLowerCase().indexOf('mp4') > -1

Changes

Files Modified (24 total):

Frontend Components:

  • apps/frontend/src/components/media/media.component.tsx - Media Library and MediaBox components
  • apps/frontend/src/components/launches/helpers/media.settings.component.tsx - Media settings editor
  • apps/frontend/src/components/agents/agent.chat.tsx - Agent chat media detection
  • libraries/react-shared-libraries/src/helpers/video.or.image.tsx - Shared video/image helper

Provider Components (Frontend):

  • X/Twitter provider
  • LinkedIn provider
  • Instagram provider
  • TikTok provider
  • YouTube provider
  • Reddit provider
  • Bluesky provider
  • Threads provider
  • Dribbble provider
  • Pinterest provider
  • Warpcast provider
  • Veo3 video provider

Backend Integrations:

  • libraries/nestjs-libraries/src/integrations/social/*.provider.ts - All social media platform integrations (X, Facebook, LinkedIn, Pinterest, Reddit, TikTok, VK, Bluesky)

Testing

Tested with uppercase .MP4 files from OpenAI Sora
Videos now correctly render using video players instead of Next.js Image
No regressions for lowercase .mp4 files
All TypeScript compilation passes with 0 errors
Dev server runs successfully on both local and Docker environments

Impact

  • ✨ Improves compatibility with AI-generated videos (Sora, Runway, etc.)
  • 🐛 Fixes Media Library display issues with uppercase video extensions
  • 🔧 Consistent behavior across all file extension cases (.mp4, .MP4, .Mp4)
  • 🎯 Affects both frontend UI components and backend social media integrations

Affected Areas

  • Media Library upload and display
  • Post creation with video attachments
  • All social media provider integrations
  • Agent chat media handling
  • Video thumbnail generation

Related Issue: Fixes media library 400 errors when uploading videos with uppercase extensions

## Problem
Video files with uppercase extensions (e.g., `.MP4`) from tools like
OpenAI Sora were being incorrectly processed by Next.js Image component
instead of video players, resulting in "400 Bad Request" errors.

The application only checked for lowercase 'mp4' in file extensions:
```typescript
media.path.indexOf('mp4') > -1
```

This failed for files with `.MP4`, `.Mp4`, or other case variations.

## Solution
Made all MP4 file detection case-insensitive by converting paths to
lowercase before checking:
```typescript
media.path.toLowerCase().indexOf('mp4') > -1
```

## Changes
- Updated 24 files across frontend and backend
- Fixed media library components (MediaBox, MultiMediaComponent)
- Fixed all provider components (X, LinkedIn, Instagram, TikTok, etc.)
- Fixed backend social media integrations
- Fixed shared video/image rendering helper components
- Fixed agent chat media detection

## Testing
- Verified with uppercase .MP4 files from OpenAI Sora
- Videos now correctly render using video players
- No regression for lowercase .mp4 files
- All TypeScript compilation passes with 0 errors

## Impact
- Improves compatibility with AI-generated videos
- Fixes media library display issues
- Consistent behavior across all file extension cases
@vercel
Copy link

vercel bot commented Oct 20, 2025

Someone is attempting to deploy a commit to the Listinai Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Video files with uppercase .MP4 extension fail to load in Media Library (400 Bad Request)

1 participant