# MongoServerError: BSONObj size: 17825792 (0x1100000) is invalid. Size must be between 0 and 16793600(16MB) First element: _id: ObjectId('...')

- **ID:** `database/mongodb-document-too-large`
- **Domain:** database
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The document being inserted or updated exceeds MongoDB's 16MB BSON document size limit.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MongoDB 6.0.10 | active | — | — |
| MongoDB 7.0.4 | active | — | — |
| MongoDB 5.0.24 | active | — | — |

## Workarounds

1. **Use GridFS to store large documents. Split the document into chunks and store them in fs.files and fs.chunks collections. Example: `mongofiles put large_document.json`** (85% success)
   ```
   Use GridFS to store large documents. Split the document into chunks and store them in fs.files and fs.chunks collections. Example: `mongofiles put large_document.json`
   ```
2. **Restructure the document to remove large arrays or subdocuments, storing them in separate collections with references.** (80% success)
   ```
   Restructure the document to remove large arrays or subdocuments, storing them in separate collections with references.
   ```

## Dead Ends

- **** — MongoDB's 16MB limit is hardcoded and cannot be changed; no such startup parameter exists. (100% fail)
- **** — Compression must be done at the storage engine level (WiredTiger), not by the application; the BSON size check occurs before storage. (90% fail)
