Custom Labels Folder Deployment

Issue #2458 resolved
Oleksandr Tymchenko created an issue

Hi,
I have project structure
force app/project1Name/labels

force app/project2Name/labels
When I’m clicking on project1Name Folder and Deploy All Metadata (with Context selected), window shows correct labels which should be deployed (ex. 441 labels)
But after clicking Deploy, labels from all other project (project1, project2 … ) 7k labels and error is thrown because too many of them for the deployment


Official response

  • Scott Wells repo owner

    Aha! This is actually due to a workaround for a CLI bug that existed at one point (and for quite a while). Here’s the comment in the code that promotes individual label deployment to be the entire set:

    // Special handling for the weird CustomLabels/CustomLabel composite metadata type. The CLI bombs out if
    // you try to deploy CustomLabel entries directly, so populate the package.xml with CustomLabels instead.
    // Note that selective retrieval of custom labels works just fine.
    

    As Oleksandr had already pointed out (via direct email) and I’ve confirmed, there are no longer issues with deployment individual labels, so I’ll remove that workaround for next week’s build of IC2.

Comments (7)

  1. Scott Wells repo owner
    • changed status to open

    Can you please enable debug logging for both Metadata Deployment and Salesforce DX, then reproduce the issue and attach (or email) the resulting idea.log file for review? I want to see how IC2 is translating the metadata selected for deployment into the actual deployment payload request. I know that there's at least one situation where, to work around an API limitation, it will change a very large request from being distinct items to a wildcard; otherwise the API will issue an error. I'm betting that's what's going on here.

  2. Scott Wells repo owner

    Thank you. It appears that IC2 is doing what it's supposed to be doing and either the Salesforce CLI or the Salesforce API/server is expanding the deployment to include all of your labels. Here is the relevant extract from the log (with all identifying information redacted/anonymized):

    2023-11-03 18:10:36,701 [ 207027]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder - Creating a metadata package for module <moduleName>.
    2023-11-03 18:10:36,701 [ 207027]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder -   Creating a metadata package based on package.xml file manifest/package.xml.
    2023-11-03 18:10:58,665 [ 228991]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder - Processing 439 build selections for file '/path/to/<moduleName>/force-app/main/default/labels/CustomLabels.labels-meta.xml' in module '<moduleName>'.
    2023-11-03 18:10:58,675 [ 229001]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder -   There are multiple build selections. Trying to determine whether or not the parent is included.
    ...
    2023-11-03 18:10:58,686 [ 229012]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder -   Adding a selective document for this file.
    2023-11-03 18:10:58,686 [ 229012]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder -   Creating a selective document for file '/path/to/<moduleName>/force-app/main/default/labels/CustomLabels.labels-meta.xml'.
    ... // Confirmed as 439 entries
    2023-11-03 18:10:58,695 [ 229021]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder -   Extracting 439 entries from '/path/to/<moduleName>/force-app/main/default/labels/CustomLabels.labels-meta.xml'.
    2023-11-03 18:10:58,695 [ 229021]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder -     Creating a temporary clone of the file.
    ... // Confirmed as 440 entries; one entry was present twice
    2023-11-03 18:10:58,746 [ 229072]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder -   The document was not changed. The file's original document should be used.
    2023-11-03 18:10:58,746 [ 229072]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder -   Adding the file's original document.
    2023-11-03 18:10:58,754 [ 229080]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder - Asked to build the following files for buildEventType=SAVE, bulkDeploy=true, forceDeploy=true: {file:///path/to/<moduleName>/force-app/main/default/labels/CustomLabels.labels-meta.xml}.
    ...
    2023-11-03 18:11:12,285 [ 242611]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder - This is for a source format module. Determining whether the metadata can be deployed via the native metadata API deployer.
    2023-11-03 18:11:12,285 [ 242611]   FINE - #com.illuminatedcloud.intellij.builder.ForceComBuilder -   Build selection 'CustomLabel>CustomLabel[<labelName>]' cannot be deployed via the API. The CLI will be used.
    ...
    2023-11-03 18:11:12,377 [ 242703]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataDeployer - Using sfdx force:source:deploy to deploy the following files for module '<moduleName>' to connection '<connectionName>': { CustomLabels.labels-meta.xml }.
    2023-11-03 18:11:12,377 [ 242703]   INFO - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataDeployer - Package.xml file found at /path/to/<moduleName>/manifest/package.xml
    2023-11-03 18:11:12,377 [ 242703]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataDeployer - Attempting to create a temporary package.xml file for selective deployment.
    2023-11-03 18:11:12,425 [ 242751]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataUtil - Created temporary package.xml file for selective deployment/retrieval:
    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns="<http://soap.sforce.com/2006/04/metadata">>
        <types>
            <members>CustomLabels</members>
            <name>CustomLabels</name>
        </types>
        <version>58.0</version>
    </Package>
    
    2023-11-03 18:11:12,435 [ 242761]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataDeployer - Created temporary package.xml file '/path/to/tmpDir/<moduleName>-<connectionName>-package.xml'.
    2023-11-03 18:11:12,435 [ 242761]   FINE - #com.illuminatedcloud.util.CommandLineUtil - Running command line: 'C:/Program Files/sf/bin/sfdx.cmd force:source:deploy -u <username> --ignoreerrors -g -x /path/to/tmpDir/<moduleName>-<connectionName>-package.xml -w 0 --json' from working directory: '/path/to/<moduleName>'.
    ...
    2023-11-03 18:12:22,146 [ 312472]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataDeployer - Processing the deployment result:
    {
      ...
      "details": {
        "componentFailures": [... 2563 failures reported],
        "runTestResult": {
          "numFailures": 0,
          "numTestsRun": 0,
          "totalTime": 0.0
        }
      },
      "done": true,
      ...
      "numberComponentErrors": 2563,
      "numberComponentsDeployed": 0,
      "numberComponentsTotal": 2563,
      ...
      "status": "SUCCEEDED_PARTIAL",
      "success": true
    }
    2023-11-03 18:12:22,146 [ 312472]   INFO - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataDeployer - Deployment status = SUCCEEDED_PARTIAL
    2023-11-03 18:12:22,146 [ 312472]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataDeployer - Processing 1 component successes.
    2023-11-03 18:12:22,146 [ 312472]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataDeployer -   Successfully deployed package.xml
    2023-11-03 18:12:22,150 [ 312476]   FINE - #com.illuminatedcloud.intellij.builder.ForceComSfdxMetadataDeployer - Processing 2563 component failures.
    

    I've confirmed that IC2 is creating a custom package.xml file for the deployment that includes only the requested 439 custom label entries and is using that package.xml file when executing the Salesforce CLI to perform the actual deployment (as indicated in the log extract above). I can also see that the CLI's failure response includes failures for 2,563 custom labels in spite of what was requested for deployment. Note that the status of SUCCEEDED_PARTIAL is because the response also includes one success for the package.xml file itself, but all custom labels are reported as failed due to:

    "problem": "custom label limit exceeded",
    "problemType": "ERROR",
    

    You should be able to reproduce this in complete isolation of IC2 by grabbing the selective package.xml file that IC2 is creating and using it for a deployment via the CLI directly from the command-line. Once you do that, I'd recommend that you log a bug in the CLI's public issue tracker so that they can address the problem where it exists.

  3. Scott Wells repo owner

    Resolving as IC2 is doing the right thing by performing (or at least trying to perform) a selective deployment of only the requested subset of metadata. The issue appears to be with the CLI and/or the API.

    Please let me know if you need assistance reproducing this outside of IC2 so that you can log it in the CLI's public issue tracker, and of course if you find that you're unable to reproduce it outside if IC2, please feel free to reopen with the respective details.

  4. Scott Wells repo owner
    • changed status to open

    Ah....I think I see the issue. The temporary package.xml file that IC2 is creating isn't expanding the CustomLabels metadata type to the CustomLabel metadata type with distinct entries for each selected custom label. If so, this is an IC2 issue. Let me play with that and see if I can reproduce it.

  5. Scott Wells repo owner

    Aha! This is actually due to a workaround for a CLI bug that existed at one point (and for quite a while). Here’s the comment in the code that promotes individual label deployment to be the entire set:

    // Special handling for the weird CustomLabels/CustomLabel composite metadata type. The CLI bombs out if
    // you try to deploy CustomLabel entries directly, so populate the package.xml with CustomLabels instead.
    // Note that selective retrieval of custom labels works just fine.
    

    As Oleksandr had already pointed out (via direct email) and I’ve confirmed, there are no longer issues with deployment individual labels, so I’ll remove that workaround for next week’s build of IC2.

  6. Log in to comment