ai icon indicating copy to clipboard operation
ai copied to clipboard

undefined messages in the body when attaching files larger than ~1 MB in v5

Open nikitatome opened this issue 1 year ago • 2 comments

Description

I'm trying to attach images using sendMessage({ text, files }) where files is a FileList. This works fine when images are relatively small, but if they are full size screenshots (larger than approximately 1 MB) then I see a TypeError: Cannot destructure property 'messages' of 'req.body' as it is undefined. error in my backend. Do we need to somehow await until we've fully received the messages object?

const router = express.Router({});

router.post('/chat/:threadId', (async (req, res) => {
  const { messages, modelName } = req.body;
}

I don't have this issue with https://ai-sdk-preview-attachments.vercel.app/ only my local v5

AI SDK Version

  • ai: 5.0.0-beta.14

nikitatome avatar Jul 14 '25 20:07 nikitatome

Nevermind, was an express limit issue in our config

nikitatome avatar Jul 14 '25 23:07 nikitatome

Identify issue type

Identified as None
Confidence: High

Rationale

This was a configuration/support issue rather than broken AI SDK behavior, and the reporter resolved it by identifying the Express limit.

Evidence

  • The reporter initially observed req.body becoming undefined for file uploads larger than approximately 1 MB.
  • The reporter later confirmed the cause was an Express request-size limit in their own configuration.

lgrammel avatar Jul 22 '26 14:07 lgrammel