How to fix STRING_TOO_LONG in Salesforce deployments
A value written to a text, picklist, or email field exceeds the maximum length defined on that field.
Surfaces during: runtime DML, in data loads, Apex tests, and Flow or Apex string-building logicWhat it means
STRING_TOO_LONG means a record insert or update is trying to write more characters into a field than its metadata allows. Standard text fields, picklists, and email fields all have a defined maximum length, and Salesforce enforces it strictly: truncation never happens silently.
Standard Text fields cap at 255 characters maximum; anything longer needs a Long Text Area or Rich Text field instead, which is why this error is a common signal that a field was simply the wrong type for the content it's now being asked to hold.
Common causes
The fix
- Increase the field length if the business case supports itRaise the field's max length in metadata if the longer values are legitimate and the field type allows it.
- Validate at the point of entryAdd a Flow or Apex guard that trims or rejects oversized values before they reach the DML operation.
String safeValue = rawValue.length() > 255 ? rawValue.left(255) : rawValue; - Audit migrated data against the target schemaCompare source data lengths to target field limits before a migration, not after the load fails.
How Serpent prevents this
Serpent's CI pipelines run a field-length validation pass before a data load reaches a shared org, so an oversized value fails fast in a pipeline step instead of mid-deployment. See the Salesforce deployment error library.

Prevention
Related errors
STRING_TOO_LONG, answered
Start free. No credit card, no install, no commitment.
Set up in under 15 minutes. No DevOps hire needed.
