forcedotcom / forcedotcom/cli

force:source:push is not deleting remote classes on a source-tracked sandbox

Open
#1,093 4 comments 0 reactions 0 assignees View on GitHub
area:mdapi bug known issue owned by another team
Dominant language
No language data
Stars
571
Forks
80
Avg merge
2d 15h
Merged PRs (30d)
3

Description

### 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):

1. Copy the source from production to git (we use Gearset for this) in sfdx source format
1. Create a new developer sandbox from production, where source-tracking is enabled
1. Clone the git repository to my local machine
1. Set the defaultusername in the local project to be the new sandbox
1. Since I know that the local code and sandbox are in sync, run `sfdx force:source:tracking:reset --noprompt`
1. Delete an Apex class locally
1. 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"
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.