Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't push when labels file is removed #3070

Open
geoffswift opened this issue Oct 19, 2024 · 9 comments
Open

Can't push when labels file is removed #3070

geoffswift opened this issue Oct 19, 2024 · 9 comments
Labels
more information required Issue requires more information or a response from the customer stale validated Version information for this issue has been validated

Comments

@geoffswift
Copy link

geoffswift commented Oct 19, 2024

Summary

If I decide I don't want the labels in example.labels-meta.xml any longer, I would expect to be able to simply delete the file.

When I try to push this change with sf project deploy start the cli fails:

Error (MetadataTransferError): Metadata API request failed: force-app/main/default/labels/example.labels-meta.xml: File or folder not found

Steps To Reproduce

  • Use a source tracked project
  • Make a labels file
  • Push the change
  • Delete the labels file
  • Try to push again (this fails)

Expected result

The deploy succeeds with the labels which were in the labels file are removed from the org.

Actual result

The push fails with:

Error (MetadataTransferError): Metadata API request failed: force-app/main/default/labels/team.labels-meta.xml: File or folder not found

Additional information

The problem is actually worse than described. I might have a git branch where a new labels file is added. If I deploy that branch but then switch back to trying to deploy main, then I can't because the file is similarly deleted by git.

Issue may not be limited to labels metadata.

System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.61.8",
  "nodeVersion": "node-v20.12.0",
  "osVersion": "Darwin 24.0.0",
  "rootPath": "/Users/[email protected]/src/cpm/node_modules/@salesforce/cli",
  "shell": "bash",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.5 (core)",
    "@oclif/plugin-commands 4.0.16 (core)",
    "@oclif/plugin-help 6.2.13 (core)",
    "@oclif/plugin-not-found 3.2.22 (core)",
    "@oclif/plugin-plugins 5.4.10 (core)",
    "@oclif/plugin-search 1.2.10 (core)",
    "@oclif/plugin-update 4.5.10 (core)",
    "@oclif/plugin-version 2.2.14 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.18 (core)",
    "@oclif/plugin-which 3.2.15 (core)",
    "@salesforce/analytics 1.4.26 (link) /Users/[email protected]/src/cpm/node_modules/@salesforce/analytics",
    "@salesforce/cli 2.61.8 (core)",
    "apex 3.5.0 (core)",
    "api 1.2.2 (core)",
    "auth 3.6.65 (core)",
    "community 3.2.35 (link) /Users/[email protected]/src/cpm/node_modules/@salesforce/plugin-community",
    "data 3.6.8 (core)",
    "deploy-retrieve 3.12.15 (core)",
    "info 3.4.9 (core)",
    "limits 3.3.32 (core)",
    "marketplace 1.2.26 (core)",
    "org 4.6.0 (core)",
    "packaging 2.8.10 (core)",
    "schema 3.3.34 (core)",
    "settings 2.3.23 (core)",
    "sobject 1.4.40 (core)",
    "source 3.5.21 (core)",
    "telemetry 3.6.15 (core)",
    "templates 56.3.21 (core)",
    "trust 3.7.32 (core)",
    "user 3.5.32 (core)"
  ]
}
@geoffswift geoffswift added the investigating We're actively investigating this issue label Oct 19, 2024
Copy link

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.

Copy link

Hello @geoffswift 👋 None of the versions of sf you shared match the latest release.

Shared: 2.61.8
Latest: 2.62.6

Update to the latest version of Salesforce CLI (docs) and confirm that you're still seeing your issue.
You can also try the rc and nightly releases! (docs)

After updating, share the full output of sf version --verbose --json

@github-actions github-actions bot added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Oct 19, 2024
@geoffswift
Copy link
Author

geoffswift commented Oct 19, 2024

Issue is still reproducible with 2.62.6

System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.62.6",
  "nodeVersion": "node-v20.12.0",
  "osVersion": "Darwin 24.0.0",
  "rootPath": "/Users/[email protected]/src/cpm/node_modules/@salesforce/cli",
  "shell": "bash",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.5 (core)",
    "@oclif/plugin-commands 4.1.3 (core)",
    "@oclif/plugin-help 6.2.14 (core)",
    "@oclif/plugin-not-found 3.2.22 (core)",
    "@oclif/plugin-plugins 5.4.14 (core)",
    "@oclif/plugin-search 1.2.11 (core)",
    "@oclif/plugin-update 4.6.3 (core)",
    "@oclif/plugin-version 2.2.14 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.18 (core)",
    "@oclif/plugin-which 3.2.15 (core)",
    "@salesforce/analytics 1.4.26 (link) /Users/[email protected]/src/cpm/node_modules/@salesforce/analytics",
    "@salesforce/cli 2.62.6 (core)",
    "apex 3.5.1 (core)",
    "api 1.3.1 (core)",
    "auth 3.6.65 (core)",
    "community 3.2.35 (link) /Users/[email protected]/src/cpm/node_modules/@salesforce/plugin-community",
    "data 3.7.0 (core)",
    "deploy-retrieve 3.12.17 (core)",
    "info 3.4.9 (core)",
    "limits 3.3.32 (core)",
    "marketplace 1.2.26 (core)",
    "org 4.6.0 (core)",
    "packaging 2.8.11 (core)",
    "schema 3.3.34 (core)",
    "settings 2.3.23 (core)",
    "sobject 1.4.41 (core)",
    "source 3.5.21 (core)",
    "telemetry 3.6.15 (core)",
    "templates 56.3.22 (core)",
    "trust 3.7.33 (core)",
    "user 3.5.32 (core)"
  ]
}

@github-actions github-actions bot added investigating We're actively investigating this issue validated Version information for this issue has been validated and removed more information required Issue requires more information or a response from the customer labels Oct 19, 2024
@iowillhoit
Copy link
Contributor

Hey @geoffswift, thanks for the issue.

I discussed this with another engineer on our team and we don't know if there is much that we can do to solve this exact use case. When you create a few Custom Labels in the org and retrieve them, it will create a single labels/CustomLabels.labels-meta.xml file that contains all of the individual Custom Labels. Once the file is deleted, we cannot look inside that file to find the names of the Labels that were deleted.

We cannot use * to delete all of them because the default name of the file is generic CustomLabels.labels-meta.xml. Using * could easily delete all custom labels across multiple package directories if the file had the same basename.

There are two work arounds that I can think of.

@geoffswift
Copy link
Author

geoffswift commented Oct 24, 2024

Using sf project delete source didn't work out that well...

$ sf project delete source --source-dir force-app/main/default/labels/test.labels-meta.xml 
? This operation will delete the following files on your computer and in your org:
CustomLabels:CustomLabels
Are you sure you want to proceed? yes

 ─────────────── Deleting Metadata ───────────────

 Deleting with SOAP API

 ✔ Preparing 155ms
 ◯ Waiting for the org to respond - Skipped
 ✔ Deploying Metadata 899ms
   ▸ Components: 1/1 (100%)
 ◯ Running Tests - Skipped
 ◯ Updating Source Tracking - Skipped
 ✔ Done 0ms

 Status: Succeeded
 Deploy ID: 0Af8B00000vOSm9SAG
 Target Org: [email protected]
 Elapsed Time: 1.49s



=== Deleted Source

 FULL NAME    TYPE         PROJECT PATH                                       
 ──────────── ──────────── ────────────────────────────────────────────────── 
 CustomLabels CustomLabels force-app/main/default/labels/test.labels-meta.xml 
$ sf project deploy start --ignore-conflicts

 ─────────────── Deploying Metadata ───────────────

 Deploying v61.0 metadata to [email protected] using the v62.0 SOAP API.

 ✔ Preparing 152ms
 ◯ Waiting for the org to respond - Skipped
 ✘ Deploying Metadata 4.50s
   ▸ Components: 2/2 (100%)
 ◼ Running Tests
 ◼ Updating Source Tracking
 ◼ Done

 Status: In Progress
 Deploy ID: 0Af8B00000vOSmJSAW
 Target Org: [email protected]
 Elapsed Time: 4.76s

Error (MetadataTransferError): Metadata API request failed: force-app/main/default/labels/test.labels-meta.xml: File or folder not found

@geoffswift
Copy link
Author

We might typically have two branches, one includes a new labels file, and the other does not.

  • Push the branch with the label file
  • Switch to a branch without the label file
  • Try sf project deploy -> Fails because file in other branch is not present
  • Try sf project delete source -> Fails because file in other branch is not present

How are we supposed to get out of this situation? Some people would use a separate scratch org for each branch because of this...

I think the ideal here is to remove the error, so it's still possible to push. Can I maybe have it work that way with sf project deploy start --ignore-conflicts?

@iowillhoit
Copy link
Contributor

Hm, I am seeing this also. I think part of the problem is that project delete source does not track source by default, but even with the --track-source option there are still issues.

Were you able to try the custom source decomposition for Custom Labels? That seems to work as you would expect.

I was able to find another work around for deleting the custom labels in a project.

  • Create a manifest for the labels
    • sf project generate manifest -m CustomLabels --name postDestructiveChanges.xml
  • Create an empty manifest
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>61.0</version>
</Package>
  • Deploy the empty manifest with the post destructive change
    • sf project deploy start --post-destructive-changes destructiveChangesPost.xml --manifest package.xml
  • Delete the local CustomLabels metadata file.
  • sf project deploy preview will show a clean status

@geoffswift
Copy link
Author

Thanks for the workaround recommendation. We are planning to migrate to the decomposed labels, so hopefully this will become a thing of the past.

@mdonnalley mdonnalley added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Dec 4, 2024
Copy link

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

@github-actions github-actions bot added the stale label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more information required Issue requires more information or a response from the customer stale validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

3 participants