force:source:push is not deleting remote classes on a source-tracked sandbox
Summary
Deleting a local file, then running force:source:push is sometimes neither deleting the file in the remote org, nor providing an error.
I'm using a CI process where the main branch in git is equal to production. A new feature is written by creating a new source-tracked sandbox with a corresponding branch in git.
When working on a new feature, if I delete an Apex class from the local source and run sfdx force:source:push, the CLI responds that it has deleted 0/0 components. Local source tracking gets updated to show that the deleted class is in sync with the sandbox org, but the class is not deleted from that org.
Steps To Reproduce:
I tried to reproduce this in a scratch org, but it seems to be specific to sandboxes. So, I don't have a neat repository to provide you with. I work for a consultancy, so I've had the chance to experience the same problem in multiple orgs.
Here is my process (early steps could be done in other ways, but provide context):
- Copy the source from production to git (we use Gearset for this) in sfdx source format
- Create a new developer sandbox from production, where source-tracking is enabled
- Clone the git repository to my local machine
- Set the defaultusername in the local project to be the new sandbox
- Since I know that the local code and sandbox are in sync, run
sfdx force:source:tracking:reset --noprompt - Delete an Apex class locally
- Run
sfdx force:source:push
Note that this only seems to apply to the original metadata. Classes that I create locally can be deleted afterwards with no issue. It’s only deletions of metadata originating in the sandbox that misbehaves. Which is why I haven't been able to provide a scratch org reproduction
Expected result
The class I deleted locally should be deleted in the sandbox org.
Actual result
The CLI responds like this:
sfdx force:source:push
*** Deploying with SOAP ***
Job ID | 0Af3O00000pAUUPSA4
SOURCE PROGRESS | ████████████████████████████████████████ | 0/0 Components
=== Pushed Source
STATE FULL NAME TYPE PROJECT PATH
─────── ───────────────────── ───────── ──────────────────────────────────────────────────────────────────
Deleted AbstractSearchRequest ApexClass unpackaged/main/default/classes/AbstractSearchRequest.cls
Deleted AbstractSearchRequest ApexClass unpackaged/main/default/classes/AbstractSearchRequest.cls-meta.xml
Afterwards, running force:source:status would make you think that the remote file is deleted, but it is not
System Information
{
"cliVersion": "sfdx-cli/7.110.0",
"architecture": "darwin-x64",
"nodeVersion": "node-v14.17.3",
"pluginVersions": [
"@dx-cli-toolbox/sfdx-toolbox-package-utils 0.5.0",
"@oclif/plugin-autocomplete 0.3.0",
"@oclif/plugin-commands 1.3.0 (core)",
"@oclif/plugin-help 3.2.2",
"@oclif/plugin-not-found 1.2.4 (core)",
"@oclif/plugin-plugins 1.10.0 (core)",
"@oclif/plugin-update 1.4.0-3 (core)",
"@oclif/plugin-warn-if-update-available 1.7.0 (core)",
"@oclif/plugin-which 1.0.3 (core)",
"@salesforce/sfdx-plugin-lwc-test 0.1.7 (core)",
"@salesforce/sfdx-scanner 2.9.1",
"@salesforce/sfdx-trust 3.6.0 (core)",
"alias 1.1.10 (core)",
"apex 0.2.2 (core)",
"auth 1.7.1 (core)",
"config 1.2.13 (core)",
"custom-metadata 1.0.12 (core)",
"data 0.5.2 (core)",
"generator 1.1.7 (core)",
"limits 1.2.1 (core)",
"mentz 1.0.1",
"org 1.6.7 (core)",
"salesforce-alm 52.1.0 (core)",
"schema 1.0.8 (core)",
"sfdx-cli 7.110.0 (core)",
"telemetry 1.2.2 (core)",
"templates 52.1.0 (core)",
"user 1.3.1 (core)"
],
"osVersion": "Darwin 20.5.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.
We have determined that the issue you reported exists in code owned by another team that uses only the official support channels. To ensure that your issue is addressed, open an official Salesforce customer support ticket with a link to this issue. We encourage anyone experiencing this issue to do the same to increase the priority. We will keep this issue open for the community to collaborate on.
This issue has been linked to a new work item: W-15160016
known issue: https://issues.salesforce.com/issue/a028c00000zIbnE/source-tracking-doesnt-track-members-that-were-created-before-the-framework-being-enabled