Skip to content

Commit 0356912

Browse files
committed
fix(providers): order the attachment failure reason by how general the cause is
The generated-document arm was checked first, so it won over both other causes and told users two things that were not true. On an inline-strategy provider — bedrock, mistral, ollama, fireworks, litellm, vertex, kimi — there is no upload path for any file, generated or not, but the message blamed the document format and implied a plain PDF would go through. On openai or google with cloud storage unconfigured it was simply false: a generated document does take the Files API path there, and that exact file uploads fine once storage exists. The one actionable fix was hidden from the operator. A provider with no upload path cannot be helped by changing the file, and a deployment with no object storage cannot reach any upload path whatever the file is, so both now outrank the format-specific case — which is left saying only what is true of it: a signed URL points at the generation source rather than the rendered file. The formatter is unchanged. It was brute-forced over every real ceiling and three million random pairs with no collision or inversion, but the test's six ceilings all divide to exact integers, so floor, round and ceil are indistinguishable on them and the limit-side rounding was unpinned. A ceiling with a fractional remainder now covers it.
1 parent f1889ad commit 0356912

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

apps/sim/executor/handlers/agent/agent-handler.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
SIM_AUTO_SYSTEM_PREAMBLE,
1616
} from '@/lib/model-router/resolve'
1717
import {
18-
isGeneratedDocumentSourceType,
1918
MODEL_SUPPORTED_IMAGE_MIME_TYPES,
2019
processFilesToUserFiles,
2120
type RawFileInput,
@@ -985,11 +984,19 @@ export class AgentBlockHandler implements BlockHandler {
985984
inlineMaxBytes
986985
)
987986
const oversized = Number.isFinite(missingFile.size) && missingFile.size > inlineMaxBytes
988-
const reason = isGeneratedDocumentSourceType(missingFile.type)
989-
? `a generated document cannot use the large-file path for provider "${providerId}"`
990-
: getProviderFileStrategy(providerId) === 'inline'
987+
/**
988+
* Ordered by how general the cause is. A provider with no upload path at all cannot be
989+
* helped by changing the file, and a deployment with no object storage cannot reach any
990+
* upload path whatever the file is — so both outrank the format-specific case. Leading
991+
* with the generated-document arm blamed the document on providers that have no upload
992+
* path for anything, and on hosts whose only real problem was unconfigured storage.
993+
*/
994+
const reason =
995+
getProviderFileStrategy(providerId) === 'inline'
991996
? `provider "${providerId}" has no large-file upload path`
992-
: 'this deployment has no cloud file storage for the large-file upload path'
997+
: !canUseProviderLargeFilePath(providerId)
998+
? 'this deployment has no cloud file storage for the large-file upload path'
999+
: `a generated document cannot use the large-file path for provider "${providerId}", because a signed URL points at the generation source rather than the rendered file`
9931000
throw new Error(
9941001
oversized
9951002
? `File "${missingFile.name}" (${sizeMB}MB) exceeds the ${inlineMB}MB inline attachment limit, and ${reason}.`

apps/sim/providers/attachments.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,13 @@ describe('attachment limit formatting', () => {
321321
const justOver = formatAttachmentSizes(limit + 1, limit)
322322
expect(justOver.size).not.toBe(justOver.limit)
323323
}
324+
325+
/**
326+
* Every ceiling above divides to an exact integer, so floor/round/ceil are indistinguishable
327+
* on them — only a ceiling with a fractional remainder pins the limit-side rounding.
328+
*/
329+
const fractional = formatAttachmentSizes(12_345_679, 12_345_678)
330+
expect(fractional.size).not.toBe(fractional.limit)
324331
})
325332

326333
it('keeps a comfortably over-limit size readable', () => {

0 commit comments

Comments
 (0)