LibreChat/api/app
Danny Avila 1455f15b7b
📄 feat: Model-Aware Bedrock Document Size Validation (#12467)
* 📄 fix: Model-Aware Bedrock Document Size Validation

Remove the hard 4.5MB clamp on Bedrock document uploads so that
Claude 4+ (PDF) and Nova (PDF/DOCX) models can accept larger files
per AWS documentation. The default 4.5MB limit is preserved for
other models/formats, and fileConfig can now override it in either
direction—consistent with every other provider.

* address review: restore Math.min for non-exempt docs, tighten regexes, add tests

- Restore Math.min clamp for non-exempt Bedrock documents (fileConfig can
  only lower the hard 4.5 MB API limit, not raise it); only exempt models
  (Claude 4+ PDF, Nova PDF/DOCX) use ?? to allow fileConfig override
- Replace copied isBedrockClaude4Plus regex with cleaner anchored pattern
  that correctly handles multi-digit version numbers (e.g. sonnet-40)
  and removes dead Alt 1 branch matching no real Bedrock model IDs
- Tighten isBedrockNova from includes() to startsWith() to prevent
  substring matching in unexpected positions
- Add integration test verifying model is threaded to validateBedrockDocument
- Add boundary tests for exempt + low configuredFileSizeLimit, non-exempt
  + high configuredFileSizeLimit, and exempt model accepting files up to 32 MB
- Revert two tests that were incorrectly inverted to prove wrong behavior
- Fix inaccurate JSDoc and misleading test name

* simplify: allow fileConfig to override Bedrock limit in either direction

Make Bedrock consistent with all other providers — fileConfig sets the
effective limit unconditionally via ?? rather than clamping with Math.min.
The model-aware defaults (4.5 MB for non-exempt, 32 MB for exempt) remain
as sensible fallbacks when no fileConfig is set.

* fix: handle cross-region inference profile IDs in Bedrock model matchers

Bedrock cross-region inference profiles prepend a region code to the
model ID (e.g. "us.amazon.nova-pro-v1:0", "eu.anthropic.claude-sonnet-4-...").
Both isBedrockNova and isBedrockClaude4Plus would miss these prefixed IDs,
silently falling back to the 4.5 MB default for eligible models.

Switch both matchers to use (?:^|\.) to anchor the vendor segment so the
pattern matches with or without a leading region prefix.
2026-03-30 16:50:10 -04:00
..
clients 📄 feat: Model-Aware Bedrock Document Size Validation (#12467) 2026-03-30 16:50:10 -04:00
index.js 🛠️ fix: Optionally add OpenID Sig. Algo. from Server Discovery (#5398) 2025-01-21 21:49:27 -05:00