Can't push after Deleting source file for an Apex class with Deleted status
Summary
Steps To Reproduce
- Have an Apex class with a Deleted status
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>63.0</apiVersion>
<status>Deleted</status>
</ApexClass>
- Push the code to your org
- Delete the source file
- Try to push to the org
Expected result
Push succeeds
Actual result
Component Failures [1] ┌───────────┬────────────────────────┬────────────────────────────────────────────────────────────┬─────────────┐ │ Type │ Name │ Problem │ Line:Column │ ├───────────┼────────────────────────┼────────────────────────────────────────────────────────────┼─────────────┤ │ ApexClass │ destructiveChanges.xml │ No ApexClass named: Example found │ │ └───────────┴────────────────────────┴────────────────────────────────────────────────────────────┴─────────────┘
Additional information
Presumably it thinks it has to remove the class from the org, despite the fact it was never actually deployed.
System Information
{
"architecture": "darwin-arm64",
"cliVersion": "@salesforce/cli/2.85.7",
"nodeVersion": "node-v22.12.0",
"osVersion": "Darwin 24.4.0",
"rootPath": "/Users/[email protected]/src/cpm/node_modules/@salesforce/cli",
"shell": "bash",
"pluginVersions": [
"@oclif/plugin-autocomplete 3.2.27 (core)",
"@oclif/plugin-commands 4.1.24 (core)",
"@oclif/plugin-help 6.2.27 (core)",
"@oclif/plugin-not-found 3.2.49 (core)",
"@oclif/plugin-plugins 5.4.36 (core)",
"@oclif/plugin-search 1.2.23 (core)",
"@oclif/plugin-update 4.6.37 (core)",
"@oclif/plugin-version 2.2.27 (core)",
"@oclif/plugin-warn-if-update-available 3.1.38 (core)",
"@oclif/plugin-which 3.2.34 (core)",
"@salesforce/analytics 1.4.39 (link) /Users/[email protected]/src/cpm/node_modules/@salesforce/analytics",
"@salesforce/cli 2.85.7 (core)",
"apex 3.6.12 (core)",
"api 1.3.3 (core)",
"auth 3.6.111 (core)",
"community 3.3.20 (link) /Users/[email protected]/src/cpm/node_modules/@salesforce/plugin-community",
"data 4.0.26 (core)",
"deploy-retrieve 3.22.4 (core)",
"info 3.4.53 (core)",
"lightning-dev 2.10.3 (link) /Users/[email protected]/src/cpm/node_modules/@salesforce/plugin-lightning-dev",
"limits 3.3.51 (core)",
"marketplace 1.3.8 (core)",
"org 5.6.1 (core)",
"packaging 2.9.5 (link) /Users/[email protected]/src/portfolio-limits-reporter/node_modules/@salesforce/plugin-packaging",
"schema 3.3.59 (core)",
"settings 2.4.23 (core)",
"sobject 1.4.54 (core)",
"telemetry 3.6.38 (core)",
"templates 56.3.44 (core)",
"trust 3.7.81 (core)",
"user 3.6.17 (core)",
"@salesforce/sfdx-scanner 4.10.0 (user) published 58 days ago (Tue Feb 25 2025) (latest is 4.11.0)"
]
}
Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.
Hi @geoffswift, I wasn't able to reproduce it. I followed the steps, apex class with a deleted status and push to the org. The status was succeed and the apexclass that was deleted showed in the state as unchanged rather than created.
@soridalac Here's a minimal reproduction...
~/src/cpm$ echo '<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"><apiVersion>63.0</apiVersion><status>Deleted</status></ApexClass>' > force-app/deprecated/classes/Test.cls-meta.xml
~/src/cpm$ echo 'public class Test {}' > force-app/deprecated/classes/Test.cls
~/src/cpm$ sf project deploy start -c
─────────────── Deploying Metadata ───────────────
Deploying v63.0 metadata to [email protected] using the v63.0 SOAP API.
✔ Preparing 307ms
◯ Waiting for the org to respond - Skipped
✔ Deploying Metadata 4.83s
▸ Components: 1/1 (100%)
◯ Running Tests - Skipped
◯ Updating Source Tracking - Skipped
✔ Done 0ms
Status: Succeeded
Deploy ID: 0AfDF00001Oa7a90AB
Target Org: [email protected]
Elapsed Time: 5.15s
Deployed Source
┌───────────┬────────────────────────────────────┬───────────┬──────────────────────────────────────────────────────────────────────────────────────────┐
│ State │ Name │ Type │ Path │
├───────────┼────────────────────────────────────┼───────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
│ Unchanged │ Test │ ApexClass │ force-app/deprecated/classes/Test.cls │
│ Unchanged │ Test │ ApexClass │ force-app/deprecated/classes/Test.cls-meta.xml │
└───────────┴────────────────────────────────────┴───────────┴──────────────────────────────────────────────────────────────────────────────────────────┘
~/src/cpm$ rm force-app/deprecated/classes/Test.cls*
~/src/cpm$ sf project deploy start -c
─────────────── Deploying Metadata ───────────────
Deploying v63.0 metadata to [email protected] using the v63.0 SOAP API.
✘ Preparing 347ms
◼ Waiting for the org to respond
◼ Deploying Metadata
◼ Running Tests
◼ Updating Source Tracking
◼ Done
Status: Failed
Deploy ID: 0AfDF00001Oa7aE0AR
Target Org: [email protected]
Elapsed Time: 364ms
Component Failures [1]
┌───────────┬────────────────────────┬────────────────────────────────┬─────────────┐
│ Type │ Name │ Problem │ Line:Column │
├───────────┼────────────────────────┼────────────────────────────────┼─────────────┤
│ ApexClass │ destructiveChanges.xml │ No ApexClass named: Test found │ │
└───────────┴────────────────────────┴────────────────────────────────┴─────────────┘
Deleted Source
┌──────┬───────────┬────────────────────────────────────────────────┐
│ Name │ Type │ Path │
├──────┼───────────┼────────────────────────────────────────────────┤
│ Test │ ApexClass │ force-app/deprecated/classes/Test.cls │
│ Test │ ApexClass │ force-app/deprecated/classes/Test.cls-meta.xml │
└──────┴───────────┴────────────────────────────────────────────────┘
From the log you should hopefully see it's trying to remove something from the org which was never actually there.
Once you get yourself into this state, you can't push any more, but you can work around the issue.
The workaround is to create a regular class with <status>Active</status> rather than ``
Hi @geoffswift I was able to issue and created a bug for us. FYI another workaround is to delete the .sf folder in your project. Thanks.
This issue has been linked to a new work item: W-18473425