Salesforce error message meaning and fix

Winter '27 API 68.0 Checked against the official docs on Source: SOAP API Developer Guide: Core Data Types, StatusCode

Quick answer

Find the status code or exception name in your Salesforce error, such as REQUIRED_FIELD_MISSING or System.QueryException, then read its cause and fix. Paste the full message below to match it against 45 common errors, or browse the list by category.

Decode an error message

The search needs JavaScript. Every error below is listed in full and grouped by category, so you can browse or use Ctrl+F.

Paste an error message to find it in the reference.

    How to read a Salesforce error

    Most Salesforce errors have two parts: a code and a message. The code is a fixed name such as UNABLE_TO_LOCK_ROW (an API status code) or System.NullPointerException (an Apex exception). The message adds details, such as the field, the record ID or the text of your own validation rule. Look up the code first.

    • API and DML errors use UPPER_SNAKE_CASE status codes. They appear in the UI, in API responses and after first error: in an Apex System.DmlException.
    • Apex errors are exceptions named after their class, such as System.QueryException, followed by a message and a stack trace with class, line and column.
    • Deployment errors come from the metadata API: compile errors, missing components and test or coverage failures. They have no status code, so search for the message text.

    Some errors are wrappers around the real cause. System.DmlException and CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY name the underlying error later in the text, after first error: or caused by:. Find the inner error in the list below.

    Where to see the full error

    In Setup, open Debug Logs, add a trace flag for the affected user and reproduce the problem. In the log, search for EXCEPTION_THROWN, FATAL_ERROR, VALIDATION_FAIL and CUMULATIVE_LIMIT_USAGE. From the CLI, sf apex tail log streams logs while you test. For limit errors, see the governor limits reference.

    Errors by category

    Data and DML

    FIELD_CUSTOM_VALIDATION_EXCEPTION

    Typical message: FIELD_CUSTOM_VALIDATION_EXCEPTION, Amount must be positive: [Amount]

    Cause

    A validation rule on the object evaluated to true, so Salesforce blocked the save. The text after the code is the error message of that rule, and the field in brackets is where the rule shows the error.

    How to fix

    1. Read the message after the code: it is the rule's own error message.
    2. In Setup, open Object Manager, the object, then Validation Rules, and find the rule with that message.
    3. Fix the data so the rule passes, or correct the rule formula if it is wrong.
    4. In Apex, catch DmlException and use getDmlMessage(0) to show the rule message to the user.

    REQUIRED_FIELD_MISSING

    Typical message: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]

    Cause

    The record is missing a value for a field that is required by the platform (such as Name), by the field definition, or by the page layout used through the API call.

    How to fix

    1. Look at the field names in brackets and set a value for each one before the insert or update.
    2. For a custom field, check whether the field itself is marked required in its definition.
    3. In a data load, check the CSV column mapping and blank cells.
    insert new Contact(FirstName = 'Ada'); // LastName is required

    DUPLICATE_VALUE

    Typical message: DUPLICATE_VALUE, duplicate value found: External_Id__c duplicates value on record with id: 001...

    Cause

    A field marked unique (or an external ID with unique values) already holds the value you are saving on another record.

    How to fix

    1. Use the record ID in the message to open the existing record.
    2. Update that record instead of inserting a new one, or change the value.
    3. In Apex or a data load, use upsert on the external ID field to update-or-insert.

    DUPLICATES_DETECTED

    Typical message: DUPLICATES_DETECTED, Use one of these records?

    Cause

    An active duplicate rule with the Block action found a likely duplicate of the record you are saving. The Allow action with an alert can be overridden by the caller.

    How to fix

    1. Open the matching records named in the error and update one of them instead.
    2. If the rule action is Allow with an alert, saving through Apex can set the duplicate rule header to allow the save.
    3. Review the matching rule if it blocks legitimate records.
    Database.DMLOptions dml = new Database.DMLOptions();
    dml.DuplicateRuleHeader.allowSave = true;
    Database.insert(acc, dml);

    STRING_TOO_LONG

    Typical message: STRING_TOO_LONG, Name: data value too large: ... (max length=80)

    Cause

    A text value is longer than the maximum length of its field. The message names the field and the maximum length.

    How to fix

    1. Shorten the value, or use the field's max length from the message as the limit.
    2. If the data legitimately needs more room, move it to a Long Text Area field.
    3. In Apex, truncate deliberately with String.abbreviate or substring before saving.

    INVALID_CROSS_REFERENCE_KEY

    Typical message: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id

    Cause

    An ID in a lookup or master-detail field does not point to a usable record: it does not exist in this org, belongs to the wrong object, was deleted, or came from another org (for example a production ID used in a sandbox).

    How to fix

    1. Check that the ID exists in this org with a SOQL query on the target object.
    2. Check the ID prefix matches the object the lookup expects.
    3. After a data migration or sandbox refresh, remap IDs instead of copying them.

    ENTITY_IS_DELETED

    Typical message: ENTITY_IS_DELETED, entity is deleted

    Cause

    The operation referenced a record that has been deleted (it may still be in the Recycle Bin).

    How to fix

    1. Confirm the record is deleted: query it with ALL ROWS in Apex, or check the Recycle Bin.
    2. Restore it with undelete if it should exist, or remove the stale reference.
    3. Refresh cached IDs in integrations that hold on to old records.
    List<Account> a = [SELECT Id FROM Account WHERE Id = :id ALL ROWS];
    undelete a;

    DELETE_FAILED

    Typical message: DELETE_FAILED, Your attempt to delete <record> could not be completed because it is associated with ...

    Cause

    The record is in use by another record or setting, such as a related record that restricts deletion, so it cannot be deleted.

    How to fix

    1. Read the end of the message: it names what the record is associated with.
    2. Remove or reassign the associated records or references first, then delete again.
    3. Check lookup fields whose delete behavior is set to Don't allow deletion.

    MALFORMED_ID

    Typical message: MALFORMED_ID, malformed id 001XXXXXXXX

    Cause

    A value passed as an ID is not a valid 15 or 18 character Salesforce ID (wrong length, stray characters, or changed case in an 18-character ID).

    How to fix

    1. Check for whitespace, quotes or truncated values in the ID.
    2. Convert and validate the ID with the ID converter.
    3. In SOQL filters, compare an ID field with a valid ID, not a name or a label.

    INVALID_TYPE_ON_FIELD_IN_RECORD

    Typical message: INVALID_TYPE_ON_FIELD_IN_RECORD, Close Date: value not of required type: ...

    Cause

    A value does not match the data type of its field, for example text in a number field or a date in the wrong format.

    How to fix

    1. Check the field named in the message and its data type.
    2. Format dates as YYYY-MM-DD and datetimes in ISO 8601 for API and data loads.
    3. Remove thousands separators and currency symbols from number values.

    ENTITY_IS_LOCKED

    Typical message: ENTITY_IS_LOCKED, entity is locked

    Cause

    The record is locked because an approval process is pending on it, so it cannot be edited until the approval finishes.

    How to fix

    1. Open the record and check for a pending approval request.
    2. Ask the approver to approve or reject it, or have an admin recall or unlock it.
    3. In automation, check Approval.isLocked or the lock status before updating.

    UNABLE_TO_LOCK_ROW

    Typical message: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record

    Cause

    Two transactions tried to update the same or related records at once, so one timed out waiting for the lock, or they deadlocked. Roll-up summary fields and child records of the same parent are common causes because the parent is locked.

    How to fix

    1. Retry the failed operation; the error is often transient.
    2. In bulk loads, lower the batch size or switch to serial processing, and sort records by parent so batches do not compete for the same parent.
    3. Avoid running many jobs against the same parent record at the same time.
    4. In Apex, SOQL FOR UPDATE locks records on purpose; keep the transaction short.

    Access and login

    INSUFFICIENT_ACCESS_OR_READONLY

    Typical message: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id

    Cause

    The running user lacks the permission or record access needed for the action, for example edit or delete rights on that record through ownership, sharing or object permissions.

    How to fix

    1. Check object permissions (create, read, edit, delete) for the user in their profile and permission sets.
    2. Check record access: the owner, role hierarchy, sharing rules and org-wide defaults for the object.
    3. Reproduce as the user: use Login As in a sandbox or run the Apex in a System.runAs test.

    INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

    Typical message: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id

    Cause

    The save affects another record that this one references (for example a lookup target or a parent), and the user cannot access that referenced record.

    How to fix

    1. Identify the referenced record from the ID in the message or from the lookup fields you are setting.
    2. Give the user access to it through sharing, or use a user who has access.
    3. In Apex that must act on records the user cannot see, run it in a class declared with sharing settings that fit the design, and document the reason.

    INVALID_SESSION_ID

    Typical message: INVALID_SESSION_ID: Session expired or invalid

    Cause

    The session ID or access token sent with the request is expired, malformed or no longer valid, or it was sent to the wrong instance URL.

    How to fix

    1. Log in or refresh the OAuth access token and retry.
    2. Use the instance_url returned at login as the base URL for API calls.
    3. Check that the Authorization header is "Bearer <token>" with no extra characters.

    INVALID_LOGIN

    Typical message: INVALID_LOGIN: Invalid username, password, security token; or user locked out.

    Cause

    The login credentials are not valid, the user is locked out, or the maximum number of logins has been exceeded.

    How to fix

    1. Verify the username and password, and that the user is active and not locked out.
    2. If logging in from an IP outside the trusted range, append the security token to the password or add the IP to a trusted range.
    3. Confirm you are using the right login URL (login.salesforce.com, test.salesforce.com or the My Domain URL).

    INVALID_FIELD_FOR_INSERT_UPDATE

    Typical message: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: <Field>. Please check the security settings of this field...

    Cause

    A field in the request cannot be written: it is read-only for the user through field-level security, or it is a formula, auto-number or system field.

    How to fix

    1. Check field-level security for the field in the user's profile and permission sets.
    2. Check the field type: formula, roll-up summary and auto-number fields cannot be set.
    3. Remove the field from the request or load file if it should not be written.

    SOQL and queries

    INVALID_FIELD

    Typical message: INVALID_FIELD: No such column 'Foo__c' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name.

    Cause

    The query names a field that does not exist on the object, is misspelled, lacks the __c suffix, or is not visible to the running user.

    How to fix

    1. Check the field API name on the object in Object Manager (labels differ from API names).
    2. Custom fields end with __c, and relationship paths use __r.
    3. Check that the user has field-level security access to the field.
    4. If the field is in a package, include the namespace prefix.
    SELECT Id, Region__c FROM Account // field must be Region__c, not Region

    MALFORMED_QUERY

    Typical message: MALFORMED_QUERY: unexpected token: 'FROM'

    Cause

    The query string has invalid SOQL syntax, or exceeds a query limit such as the maximum query length.

    How to fix

    1. Look at the token named in the message and the text right before it.
    2. Check commas between fields, quotes around strings and the order SELECT, FROM, WHERE, GROUP BY, ORDER BY, LIMIT.
    3. Test the query in the Developer Console Query Editor.

    INVALID_TYPE

    Typical message: INVALID_TYPE: sObject type 'Foo' is not supported.

    Cause

    The object name in the query or API call does not exist, is misspelled, lacks __c, or the user cannot see the object.

    How to fix

    1. Check the object API name in Object Manager.
    2. Custom objects end with __c.
    3. Check that the user has Read access to the object.

    QUERY_TIMEOUT

    Typical message: QUERY_TIMEOUT: Your query request was running for too long.

    Cause

    The query took too long, usually because it filters on non-indexed fields over a large object or returns too much data.

    How to fix

    1. Filter on indexed fields (such as Id, Name, lookups, external IDs) and use a narrower date range.
    2. Remove leading wildcards and negative filters like != where you can.
    3. For large exports, use Bulk API or query in smaller slices.

    System.QueryException: Non-selective query against large object type

    Typical message: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.

    Cause

    A query in a trigger filters on fields that are not selective on an object with a large number of records, so Salesforce refuses to run it.

    How to fix

    1. Add a filter on an indexed field that narrows the results to a small share of records.
    2. Avoid filtering on formula fields or fields with mostly the same value.
    3. Ask Salesforce Support about a custom index when the filter is correct but still not selective.

    System.QueryException: Aggregate query has too many rows for direct assignment

    Typical message: System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop

    Cause

    A query that returns more rows than direct assignment to a list or variable allows was assigned directly.

    How to fix

    1. Use a SOQL for loop to process the rows in chunks.
    2. Add filters or LIMIT to return fewer rows.
    for (Account a : [SELECT Id FROM Account]) {
        // process one record at a time
    }

    System.QueryException: List has no rows for assignment to SObject

    Typical message: System.QueryException: List has no rows for assignment to SObject

    Cause

    Apex assigned the result of a query straight to a single record, but the query returned no rows (or more than one, which gives a different message).

    How to fix

    1. Assign the query to a List and check isEmpty() or size() before using it.
    2. Or add LIMIT 1 and handle the empty case.
    3. In tests, create the data the query expects.
    List<Account> rows = [SELECT Id FROM Account WHERE Name = :n LIMIT 1];
    if (!rows.isEmpty()) {
        Account a = rows[0];
    }

    System.SObjectException

    Typical message: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Account.Industry

    Cause

    Apex read a field on a record that was queried without that field in its SELECT list.

    How to fix

    1. Add the named field to the SELECT list of the query that loaded the record.
    2. If the record was passed in from elsewhere, query it again with the fields you need.

    Apex runtime

    System.NullPointerException

    Typical message: System.NullPointerException: Attempt to de-reference a null object

    Cause

    Code called a method or read a field on a variable that is null, such as an unqueried relationship, an empty map lookup or an uninitialised variable.

    How to fix

    1. Use the line and column in the stack trace to find the expression that is null.
    2. Add null checks, or use the safe navigation operator ?. in Apex.
    3. Initialise collections, and check map.get(key) results before using them.
    String name = acc?.Owner?.Name; // returns null instead of throwing

    System.DmlException

    Typical message: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]

    Cause

    A DML statement failed. This is a wrapper: the real reason is the status code after "first error:".

    How to fix

    1. Find the status code after "first error:" and look it up in this list.
    2. The row number is zero-based: row 0 is the first record in the list.
    3. Use Database.insert(records, false) and inspect each SaveResult to see every failure instead of only the first.
    Database.SaveResult[] res = Database.insert(records, false);
    for (Database.SaveResult r : res) {
        if (!r.isSuccess()) System.debug(r.getErrors()[0].getStatusCode() + ': ' + r.getErrors()[0].getMessage());
    }

    System.CalloutException: You have uncommitted work pending

    Typical message: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

    Cause

    Apex made a callout after DML in the same transaction. A callout is not allowed while there are uncommitted changes.

    How to fix

    1. Make the callout before the DML.
    2. Or move the callout (or the DML) to a Queueable or @future method so it runs in its own transaction.

    System.TypeException

    Typical message: System.TypeException: Invalid conversion from runtime type Account to Contact

    Cause

    A cast or conversion is not valid for the actual runtime type of the value, or a string could not be converted to a number, date or ID.

    How to fix

    1. Check the real type with instanceof before casting.
    2. Validate strings before converting them to numbers or dates.

    MIXED_DML_OPERATION

    Typical message: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa)

    Cause

    One transaction changed both a setup object (such as User, Group or PermissionSetAssignment) and a non-setup object (such as Account). Salesforce limits this mix.

    How to fix

    1. Move one of the DML operations to a separate transaction, such as a Queueable or @future method.
    2. In tests, wrap the setup-object DML in System.runAs(user) { ... }.

    SELF_REFERENCE_FROM_TRIGGER

    Typical message: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001...) is currently in trigger X, therefore it cannot recursively update itself

    Cause

    A trigger updated or deleted the same record it is running for, in a way that is not allowed, such as updating the record from its own before trigger by DML.

    How to fix

    1. In a before trigger, set field values on Trigger.new directly instead of using DML.
    2. Do not delete the triggering record from its own trigger.
    3. Use a static flag to guard against recursion if two triggers update each other.

    CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

    Typical message: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MyTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object

    Cause

    An error occurred in a trigger, flow or process that ran while saving. This is a wrapper: the real error is the exception named after "caused by". The status code can also mean a missing permission to create, update or activate the record.

    How to fix

    1. Read the text after "caused by:" and find that exception in this list.
    2. The trigger name and line number in the message show where it failed.
    3. Reproduce with the same data and open the debug log to see the execution path.

    Variable does not exist

    Typical message: Variable does not exist: Region__c

    Cause

    An Apex compile error: the code uses a variable or field that does not exist in the org, is misspelled, or is not visible to the code (for example a field missing in the target org).

    How to fix

    1. Check the spelling and the API name of the field or variable.
    2. If it is a custom field, confirm it exists in the org you are saving or deploying to.
    3. When deploying, include the field in the deployment or deploy it first.

    Integration and API

    REQUEST_LIMIT_EXCEEDED

    Typical message: REQUEST_LIMIT_EXCEEDED: TotalRequests Limit exceeded.

    Cause

    The org exceeded either the concurrent request limit or the request limit for its API usage, so Salesforce rejects new API requests.

    How to fix

    1. Check API usage in Setup under System Overview and the Limits resource of the REST API.
    2. Batch work: use composite requests, Bulk API or sObject Collections to use fewer calls.
    3. Cache reads and avoid polling in tight loops; stop runaway integrations.

    System.CalloutException: Unauthorized endpoint

    Typical message: System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings.

    Cause

    Apex called an external URL that is not allowed: the URL is not registered as a Remote Site Setting, or it is not covered by a Named Credential.

    How to fix

    1. Prefer a Named Credential for the callout and use the callout: URL syntax.
    2. Or add the exact base URL as a Remote Site Setting in Setup.
    3. Check the protocol and host; http and https are different.

    invalid_grant

    Typical message: {"error":"invalid_grant","error_description":"authentication failure"}

    Cause

    An OAuth token request was refused. Common reasons: wrong username, password or token, a user the connected app does not allow, an expired or revoked refresh token, or a login URL that does not match the org (production versus sandbox or My Domain).

    How to fix

    1. Check the token endpoint host matches the org type (login.salesforce.com, test.salesforce.com or your My Domain).
    2. Check the connected app policies: permitted users and pre-authorized profiles or permission sets.
    3. For JWT bearer flow, check the username, the certificate and that the app is pre-authorized for that user.
    4. Request a new refresh token if the old one was revoked.

    Governor limits

    System.LimitException: Too many SOQL queries

    Typical message: System.LimitException: Too many SOQL queries: 101

    Cause

    A transaction ran more SOQL queries than the per-transaction governor limit, usually a query inside a loop.

    How to fix

    1. Move queries out of loops: collect IDs first, then query once with IN :ids.
    2. Store results in a Map to look them up inside the loop.
    3. Check the debug log for the CUMULATIVE_LIMIT_USAGE section to see which code ran the queries.

    System.LimitException: Apex CPU time limit exceeded

    Typical message: System.LimitException: Apex CPU time limit exceeded

    Cause

    Apex code, triggers, flows and other automation in the transaction used more CPU time than allowed. Nested loops, heavy string work and many automations on one record are common causes.

    How to fix

    1. Use the debug log with limits and profiling to find the slow code.
    2. Replace nested loops over lists with Maps.
    3. Move long work to Queueable or Batch Apex.
    4. Check for many triggers, flows and process automation firing on the same object.

    Deployment

    Code coverage failure: Average test coverage across all Apex Classes and Triggers is below the required percent

    Typical message: Code coverage failure: Average test coverage across all Apex Classes and Triggers is 62%, at least 75% required

    Cause

    A deployment to production that runs tests did not reach the required org-wide Apex test coverage of 75 percent.

    How to fix

    1. Write tests for the classes with the lowest coverage; assert behavior, not only coverage.
    2. Run all local tests in a sandbox and check coverage per class before deploying.
    3. Check that failing tests are not lowering coverage.

    Test coverage of selected Apex Trigger is 0%

    Typical message: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

    Cause

    A trigger in the deployment has no test coverage. Triggers need some coverage to deploy to production.

    How to fix

    1. Write a test that inserts, updates or deletes records so the trigger runs.
    2. Include that test class in the deployment and run it.
    3. Make sure the test creates its own data and performs the DML the trigger listens for (insert, update or delete).
    @isTest
    private class AccountTriggerTest {
        @isTest static void insertsFireTrigger() {
            insert new Account(Name = 'Test');
        }
    }

    no CustomObject named X found

    Typical message: In field: object - no CustomObject named Invoice__c found

    Cause

    A component in the deployment (a layout, permission set, profile, flow or field) refers to an object that is neither in the target org nor part of this deployment. The same message pattern applies to other types, such as "no CustomField named ...".

    How to fix

    1. Add the missing object or field to the package.xml or deploy source so it ships in the same deployment.
    2. Check the object API name spelling and the namespace prefix.
    3. If the component should not reference it, remove the reference from the metadata file.

    Dependent class is invalid and needs recompilation

    Typical message: Dependent class is invalid and needs recompilation: Class MyClass : Variable does not exist: Region__c

    Cause

    An Apex class that the deployed code depends on no longer compiles, often because a field or class it uses was changed, removed or is missing in the target org.

    How to fix

    1. Read the text after the second colon: it is the actual compile error in the dependent class.
    2. Deploy the missing or changed fields and classes together with the code.
    3. Recompile all classes in Setup after fixing the cause.

    Frequently asked questions

    What is the difference between an error code and an error message in Salesforce?

    The code is a fixed identifier such as REQUIRED_FIELD_MISSING or System.NullPointerException that says what kind of failure happened. The message is human-readable text that can include field names, IDs or your own validation rule text. Search for the code first, then use the message to find the field or record.

    What does "first error" mean in a System.DmlException?

    System.DmlException is a wrapper. The text after "first error:" is the real status code and message for the first failing record, and "row 0" is the first record in the list because rows are counted from zero. Using Database.insert with allOrNone set to false lets you read the error of every record.

    Why does CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY appear with another exception after "caused by"?

    It wraps an error raised by a trigger, flow or process that ran while the record was being saved. The exception after "caused by" is the real problem, and the trigger name and line number show where it happened. Without a "caused by" part, the code can also mean you lack permission to create, update or activate the record.

    How do I see the full error for an Apex or automation failure?

    Open Debug Logs in Setup, add a trace flag for the user, reproduce the problem and open the log. Search it for EXCEPTION_THROWN, FATAL_ERROR, VALIDATION_FAIL and CUMULATIVE_LIMIT_USAGE. In VS Code or the CLI you can also tail logs with sf apex tail log.

    Is this list complete?

    No. Salesforce documents hundreds of status codes, and this page covers 45 of the most common errors with advice written by SFDX Talk. For a code that is not listed, check the StatusCode list in the SOAP API Developer Guide, which is linked as the source.

    Does the decoder send my error message anywhere?

    No. Matching runs in your browser and the text you paste is not sent to SFDX Talk or anyone else. Still, remove record IDs, names and other customer data from errors before you share them with others.

    More tools

    SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Salesforce changes its platform every release, so confirm against the official page before relying on a value.