What does "Entity of type cannot be found" mean?
You asked the org for a component by type and name, and it has none. This is mostly a retrieve message, so it shows up when you pull source, run a retrieve against a manifest, or sync a project. It is not a deploy failure.
A retrieve of a class that does not exist puts this in the messages list of the result:
Entity of type 'ApexClass' named 'LegacyQuoteHelper' cannot be found
The result status of that retrieve was Succeeded. A script that only checks the status will think everything came down, and the file is not there.
What causes it?
- A typo in the member name, or the wrong type for that name. People have hit the message for a
CustomApplicationnamedCase, which is an object name used under the wrong type (Salesforce Stack Exchange). - Someone deleted or renamed the component in the org after your manifest or source tracking was written. The same message is reported for list views during a pull (Salesforce Stack Exchange).
- The component belongs to a feature this org does not have. A record type named
Account.Business_Accountproduced the message for someone using Person Accounts (Salesforce Stack Exchange). - You are pointed at the wrong org. A production alias in place of a sandbox is common.
What is the matching message on a destructive deploy?
If you delete a component through destructiveChanges.xml and the component is already gone, Salesforce does not fail. It warns:
destructiveChanges.xml | Warning | No ApexClass named: OldQuoteCleanup found
A check-only run returns a warning on the destructive file, not an error. Treat it as the same signal: the name you gave does not exist in that org.
How do I fix it in Setup?
- Find the component by hand. Open Setup and look in the place that type lives, for example Apex Classes or Object Manager, Record Types.
- If it is there, copy the exact API name. Check capitals, underscores and the
__cending. - If it is not there, find out who removed it. Setup, View Setup Audit Trail lists recent changes to the org.
- Fix the manifest or source, or recreate the component.
How do I fix it with the CLI?
Confirm which org you are on, then list what exists for that type:
sf org display -o target-org
sf org list metadata --metadata-type ApexClass -o target-org
Compare the output with your manifest. Remove members that are not there, then retrieve again and read the messages as well as the status. For source tracking problems, a reset of the tracking files is sometimes needed, but check the name first.
How do I avoid it?
Generate manifests from the project rather than writing them by hand. Run the retrieve in a job and fail the job if the messages list holds an entity-not-found line. See package.xml errors for the deploy-side twin of this error. The Salesforce glossary explains why sandboxes drift from production, and AI Salesforce deployments compares two orgs so you see what exists where before you build a bundle.
Questions about entity not found
Is this a deploy error?
Usually not. It appears on retrieve and pull. The deploy-side version is a manifest message, like was named in package.xml but was not found.
Why does my retrieve say Succeeded?
The retrieve itself worked. The missing component is reported in the messages list, which is easy to skip.
Does it matter that a destructive change only warns?
It is fine when the goal is that the component is gone. It also hides a typo in the name, so read the warning.
Can a wrong org cause this?
Yes, and it is the first thing to rule out. Run sf org display and confirm the alias points where you think it does.