Sub topic 12
Fixing common deployment errors
This chapter assumes you can retrieve metadata with Salesforce CLI, read a package.xml manifest, and run sf project deploy start. It also assumes you know how an agent maps to the Bot, BotVersion, GenAiPlanner, GenAiPlugin, and GenAiFunction metadata types. Most agent deployment failures come from a missing dependency, a target org that is not ready, or a permission gap. The sections below show how to read the error and fix the cause.
Read the failure before changing anything
A failed deployment returns a list of component failures. Each entry names a component, a problem, and often a line number. Fix the first failure in the list, then redeploy, because later errors are often side effects of earlier ones. Run the validation-only deployment from the deploy chapter again after each fix so you do not change the target org while you debug.
sf project deploy start \
--manifest manifest/package.xml \
--target-org target-org \
--dry-run
sf project deploy report --use-most-recent --target-org target-orgThe second command shows the result of the most recent deployment, including every component error.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| `GenAiFunction` fails with a "not found" error for an Apex class or Flow | The action's target was not in the manifest, or it failed to deploy | Add the `ApexClass` or `Flow` member to `package.xml` and deploy it in the same run |
| `Bot` or `GenAiPlanner` is not a valid metadata type | Agentforce or Einstein generative AI is not enabled in the target org | Enable the features listed in the readiness chapter, then redeploy |
| Apex class fails to compile in the target | The class references a field, object, or another class that does not exist there | Deploy the missing object or field first, or add it to the manifest |
| Flow fails with a missing reference | The flow uses a custom field, record type, or subflow absent in the target | Include the dependency, then redeploy the flow |
| Agent deploys but the agent user is not found | The username in the agent configuration exists only in the source org | Create the user in the target org and update the value for that environment |
| Agent deploys but cannot run an action | The agent user lacks access to the Apex class or Flow | Assign the permission set that grants that access |
| Activation fails | A required component is missing or invalid | Check the version and its topics, then activate again |
Dependency order problems
Salesforce resolves dependencies inside a single deployment. If you split the agent and its Apex classes across two deployments, deploy the classes first. The diagram shows a safe order.
Errors that appear only after a successful deploy
A deployment can succeed and the agent can still fail. A successful deploy only proves the metadata was accepted. It does not prove the agent user exists or has access.
- Confirm the agent user exists in the target org and is active.
- Assign the permission set to that user.
- Activate the agent.
- Run a test conversation that triggers each action.
sf org assign permset --name Agent_Action_Access --target-org target-org
sf agent activate --api-name My_Service_Agent --target-org target-orgIf an action still fails at run time, check that the Apex class is enabled for the agent user through the permission set. Then check that any Flow the action calls is active.
A repeatable checklist
- Read the first error, not the last.
- Confirm that every Apex class, Flow, and permission set the actions use is in the manifest.
- Confirm the target org has the required features turned on.
- Validate with
--dry-runbefore every real deployment. - Assign permissions before you activate and test.
Exercise
Your deployment of a GenAiFunction fails because it cannot find an Apex class. The class exists in the source org. Name two possible causes and the fix for each.
Show answer
First, the class was not listed in package.xml, so it was never sent to the target. Add the ApexClass member and redeploy. Second, the class was included but failed to compile in the target, for example because it references a missing field or object. Deploy the missing dependency, then redeploy. In both cases, validate with --dry-run before the real deployment.
Exercise
A deployment succeeds, but the agent cannot run one of its actions in the target org. What do you check first?
Show answer
Check that the agent user exists and has a permission set that grants access to the action's Apex class or Flow. Then confirm that any Flow involved is active and that the agent is activated.