forcedotcom / cli

Salesforce CLI
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
BSD 3-Clause "New" or "Revised" License
491 stars 79 forks source link

`sf project deploy start` does not print any errors if a component fails to deploy. #2561

Closed tarcang closed 10 months ago

tarcang commented 11 months ago

Summary

When I use the new sf project deploy start command to deploy my apex classes and flows, if there are any errors it is not printed. I get an output like this:

16:27:12  Deploying v59.0 metadata to epic.1a0e115dbbe2@salesforce.com using the v59.0 SOAP API.
16:27:13  Deploy ID: 0AfX20000000MjhKAE
16:27:13  Status: {status} | 0/0 Components (Errors:{errorCount}) {testInfo}
16:27:15  Status: In Progress | 24/41 Components (Errors:0) | 0/0 Tests (Errors:0)
16:27:15  Status: Failed | 42/42 Components (Errors:1) | 0/0 Tests (Errors:0)

However, if I use the soon to be deprecated command for this task, sfdx force:source:deploy, I do get an error printed out like so:


Deploying v59.0 metadata to epic.1a0e115dbbe2@salesforce.com using the v59.0 SOAP API.
Deploy ID: 0AfX20000000MjiKAE
DEPLOY PROGRESS | ████████████████████████████████████████ | 41/41 Components

=== Component Failures [1]

 Type  Name                             Problem                                                                                                                                    
 ───── ──────────────────────────────── ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
 Error Abandoned_Cart_Demo_V2.flow-meta An object 'Abandoned_Cart_Demo_V2.flow-meta' of type EmailServicesFunction was named in package.xml, but was not found in zipped directory 

There is something wrong with the sf project deploy start which makes it hard to debug deployment issues if it occurs.

Steps To Reproduce

IMPORTANT Provide a repository that's configured to reproduce the issue. If you are unable to provide a repo, please explain why not. The more info we have from the start, the faster we can resolve your issue. We may close your issue if you don't include proper instructions.

  • Generate a project with sf project generate or fork dreamhouse-lwc.
  • Provide detailed step-by-step instructions on how to reproduce the issue.
  1. Create a data cloud org from org farm
  2. Create connected app in that org
  3. Authorize the org with sf
  4. Clone dreamhouse-lwc
  5. Rename the flow file under force-app/main/default/flows/ to be a .flow file instead of .flow-meta.xml (So the new name of the file would be Create_property.flow). This should be an error normally because you cannot deploy .flow files, it has to be converted.
  6. Run sf project deploy start -o <YOUR_ORG> You will see something like this:
Deploying v59.0 metadata to epic.582cb02eb56e@salesforce.com using the v59.0 SOAP API.
Deploy ID: 0AfSB000000cgW50AI
Status: Failed | ████████████████████████████████████████ | 91/91 Components (Errors:1) | 0/0 Tests (Errors:0)
  1. Now run sfdx force source deploy -u <YOUR_ORG> -p main/default/ Now this should appear
Deploying v59.0 metadata to epic.582cb02eb56e@salesforce.com using the v59.0 SOAP API.
Deploy ID: 0AfSB000000cgZJ0AY
DEPLOY PROGRESS | ████████████████████████████████████████ | 90/90 Components

=== Component Failures [1]

 Type  Name            Problem                                                                                                  
 ───── ─────────────── ──────────────────────────────────────────────────────────────────────────────────────────────────────── 
 Error Create_property An object 'Create_property' of type Flow was named in package.xml, but was not found in zipped directory 

Expected result

sf project deploy start should also have printed the error.

Actual result

sf project deploy start didn't print the error although it recognized there is one.

System Information

MacBook Pro Intel (2019) Using /bin/sh

{
  "architecture": "darwin-x64",
  "cliVersion": "@salesforce/cli/2.16.7",
  "nodeVersion": "node-v20.8.1",
  "osVersion": "Darwin 23.1.0",
  "rootPath": "/Users/tarcan.gul/.local/share/sf/client/2.16.7-ee67deb",
  "shell": "bash",
  "pluginVersions": [
    "@mshanemc/plugin-streaming 1.1.7 (user)",
    "@mshanemc/sfdx-sosl 1.1.0 (user)",
    "@oclif/plugin-autocomplete 3.0.1 (core)",
    "@oclif/plugin-commands 3.0.5 (core)",
    "@oclif/plugin-help 6.0.5 (core)",
    "@oclif/plugin-not-found 3.0.2 (core)",
    "@oclif/plugin-plugins 4.0.1 (core)",
    "@oclif/plugin-search 1.0.5 (core)",
    "@oclif/plugin-update 4.1.3 (core)",
    "@oclif/plugin-version 2.0.4 (core)",
    "@oclif/plugin-warn-if-update-available 3.0.2 (core)",
    "@oclif/plugin-which 3.0.7 (core)",
    "@salesforce/cli 2.16.7 (core)",
    "@salesforce/commerce 248.1.3 (user)",
    "apex 2.3.20 (core)",
    "auth 2.8.25 (core)",
    "community 2.4.8 (user)",
    "data 2.6.1 (core)",
    "deploy-retrieve 1.19.3 (core)",
    "info 2.6.51 (core)",
    "limits 2.3.41 (core)",
    "login 1.2.40 (core)",
    "marketplace 0.3.2 (core)",
    "org 2.11.7 (core)",
    "schema 2.3.32 (core)",
    "settings 1.4.37 (core)",
    "sobject 0.2.14 (core)",
    "source 2.10.46 (core)",
    "telemetry 2.3.8 (core)",
    "templates 55.5.17 (core)",
    "trust 2.6.22 (core)",
    "user 2.3.41 (core)",
    "shane-sfdx-plugins 4.43.0 (user)"
  ]
}
github-actions[bot] commented 11 months ago

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.

github-actions[bot] commented 11 months ago

Hello @tarcang :wave: It looks like you didn't include the full Salesforce CLI version information in your issue. Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

A few more things to check:

Thank you!

github-actions[bot] commented 11 months ago

Hello @tarcang :wave: None of the versions of sf you shared match the latest release.

Shared: 2.15.9 Latest: 2.16.7

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

git2gus[bot] commented 11 months ago

This issue has been linked to a new work item: W-14470146

tbozinis commented 10 months ago

Same issue if you run the following command.

sf project deploy validate --test-level RunLocalTests --metadata-dir ./toDeploy --target-org hotfix --wait 45 --junit --results-dir tests --coverage-formatters cobertura --json > deploy-result.json

response

{
  "code": 1,
  "context": "DeployMetadataValidate",
  "commandName": "DeployMetadataValidate",
  "data": {
    "deployId": "0Af1X00002h5J2sSAE"
  },
  "message": "Failed to validate the deployment (0Af1X00002h5J2sSAE). Due To:\n1 component error(s)",
  "name": "FailedValidationError",
  "status": 1,
  "stack": "FailedValidationError: Failed to validate the deployment (0Af1X00002h5J2sSAE). Due To:\n1 component error(s)\n    at Messages.createError (/Users/tbozinis/.local/share/sf/client/2.17.14-31db5eb/node_modules/@salesforce/core/lib/messages.js:393:16)\n    at DeployMetadataValidate.run (/Users/tbozinis/.local/share/sf/client/2.17.14-31db5eb/node_modules/@salesforce/plugin-deploy-retrieve/lib/commands/project/deploy/validate.js:80:18)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async DeployMetadataValidate._run (/Users/tbozinis/.local/share/sf/client/2.17.14-31db5eb/node_modules/@salesforce/plugin-deploy-retrieve/node_modules/@oclif/core/lib/command.js:117:22)\n    at async Config.runCommand (/Users/tbozinis/.local/share/sf/client/2.17.14-31db5eb/node_modules/@oclif/core/lib/config/config.js:400:25)\n    at async run (/Users/tbozinis/.local/share/sf/client/2.17.14-31db5eb/node_modules/@oclif/core/lib/main.js:85:16)",
  "exitCode": 1,
  "warnings": []
}

with exceptions

sfdx force:source:deploy -c -l RunLocalTests -p ./toDeploy --target-org hotfix --wait 45 --junit --resultsdir tests --coverageformatters cobertura --json > test.json

{
  "status": 1,
  "result": {
    "checkOnly": true,
    "completedDate": "2023-11-17T11:25:16.000Z",
    "createdBy": "0050X000008Ti3Q",
    "createdByName": "Admin User",
    "createdDate": "2023-11-17T11:25:06.000Z",
    "details": {
      "componentFailures": [
        {
          "changed": false,
          "columnNumber": 3,
          "componentType": "ApexClass",
          "created": false,
          "createdDate": "2023-11-17T11:25:13.000Z",
          "deleted": false,
          "fileName": "classes/AccountTriggerHandler.cls",
          "fullName": "AccountTriggerHandler",
          "lineNumber": 14,
          "problem": "Missing ';' at 'Integer'",
          "problemType": "Error",
          "success": false
        }
      ],
      "componentSuccesses": [
        {
          "changed": true,
          "componentType": "",
          "created": false,
          "createdDate": "2023-11-17T11:25:14.000Z",
          "deleted": false,
          "fileName": "package.xml",
          "fullName": "package.xml",
          "success": true
        }
      ],
      "runTestResult": {
        "numFailures": 0,
        "numTestsRun": 0,
        "totalTime": 0,
        "codeCoverage": [],
        "codeCoverageWarnings": [],
        "failures": [],
        "flowCoverage": [],
        "flowCoverageWarnings": [],
        "successes": []
      }
    },
    "done": true,
    "id": "0Af1X00002h5J3xSAE",
    "ignoreWarnings": false,
    "lastModifiedDate": "2023-11-17T11:25:16.000Z",
    "numberComponentErrors": 1,
    "numberComponentsDeployed": 0,
    "numberComponentsTotal": 1,
    "numberTestErrors": 0,
    "numberTestsCompleted": 0,
    "numberTestsTotal": 0,
    "rollbackOnError": true,
    "runTestsEnabled": true,
    "startDate": "2023-11-17T11:25:12.000Z",
    "status": "Failed",
    "success": false,
    "deployedSource": [
      {
        "fullName": "AccountTriggerHandler",
        "type": "ApexClass",
        "state": "Failed",
        "error": "Missing ';' at 'Integer' (14:3)",
        "problemType": "Error",
        "filePath": "/Users/tbozinis/VS Code Projects/sfdc-dg/toDeploy/classes/AccountTriggerHandler.cls",
        "lineNumber": 14,
        "columnNumber": 3
      }
    ],
    "outboundFiles": [],
    "deploys": [
      {
        "checkOnly": true,
        "completedDate": "2023-11-17T11:25:16.000Z",
        "createdBy": "0050X000008Ti3Q",
        "createdByName": "Admin User",
        "createdDate": "2023-11-17T11:25:06.000Z",
        "details": {
          "componentFailures": [
            {
              "changed": false,
              "columnNumber": 3,
              "componentType": "ApexClass",
              "created": false,
              "createdDate": "2023-11-17T11:25:13.000Z",
              "deleted": false,
              "fileName": "classes/AccountTriggerHandler.cls",
              "fullName": "AccountTriggerHandler",
              "lineNumber": 14,
              "problem": "Missing ';' at 'Integer'",
              "problemType": "Error",
              "success": false
            }
          ],
          "componentSuccesses": [
            {
              "changed": true,
              "componentType": "",
              "created": false,
              "createdDate": "2023-11-17T11:25:14.000Z",
              "deleted": false,
              "fileName": "package.xml",
              "fullName": "package.xml",
              "success": true
            }
          ],
          "runTestResult": {
            "numFailures": 0,
            "numTestsRun": 0,
            "totalTime": 0,
            "codeCoverage": [],
            "codeCoverageWarnings": [],
            "failures": [],
            "flowCoverage": [],
            "flowCoverageWarnings": [],
            "successes": []
          }
        },
        "done": true,
        "id": "0Af1X00002h5J3xSAE",
        "ignoreWarnings": false,
        "lastModifiedDate": "2023-11-17T11:25:16.000Z",
        "numberComponentErrors": 1,
        "numberComponentsDeployed": 0,
        "numberComponentsTotal": 1,
        "numberTestErrors": 0,
        "numberTestsCompleted": 0,
        "numberTestsTotal": 0,
        "rollbackOnError": true,
        "runTestsEnabled": true,
        "startDate": "2023-11-17T11:25:12.000Z",
        "status": "Failed",
        "success": false,
        "deployedSource": [
          {
            "fullName": "AccountTriggerHandler",
            "type": "ApexClass",
            "state": "Failed",
            "error": "Missing ';' at 'Integer' (14:3)",
            "problemType": "Error",
            "filePath": "/Users/tbozinis/VS Code Projects/sfdc-dg/toDeploy/classes/AccountTriggerHandler.cls",
            "lineNumber": 14,
            "columnNumber": 3
          }
        ],
        "outboundFiles": []
      }
    ],
    "coverage": {
      "cobertura": "tests/coverage/cobertura.xml"
    }
  },
  "warnings": [
    "We plan to deprecate this command in the future. Try using the \"project deploy start\" command instead."
  ]
}