Open lmondigo opened 2 weeks ago
Hello @lmondigo :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:
rc
or nightly
versions. (docs)doctor
command to diagnose common issues.Thank you!
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.
Hello @lmondigo :wave: None of the versions of sf
you shared match the latest release.
Shared: 2.56.4
Latest: 2.56.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
We set the exit code for project deploy start
based on the deployment result status here:
that happens after the deployment finished being processed in your org and by looking at the Status: Failed
line it suggest that was the deploy status:
(this is where Status: Failed
is printed, the Failed
string comes from the deploy result payload:
https://github.com/salesforcecli/plugin-deploy-retrieve/blob/167dc693d2f06bf2a5e0c2a63e384e14d5dc6c65/src/utils/progressBar.ts#L52
I tried a few possible scenarios but couldn't get the determineExitCode
function to return 0
on a non-successful deploy (using sf v2.57.7).
does azure logs somewhere the exit code of the command?
Thanks for checking @cristiand391
I have checked the JSON response from both jobs via sf project deploy report
(see below) and both seem to be identical in terms of status
, result.status
, and result.success
.
Would it be right to assume that status
is 0 because the job is completed from the org?
I'm also curious about which field is being returned to the terminal to be parsed by the script.
{
"status": 0,
"result": {
"checkOnly": false,
"completedDate": "2024-08-28T04:06:20.000Z",
"createdBy": "0052P000000K5Mw",
"createdByName": "Script User",
"createdDate": "2024-08-28T04:06:15.000Z",
"details": {
"componentFailures": [...],
"componentSuccesses": [...],
"runTestResult": {...}
},
"done": true,
"id": "0Af9p00000xxx",
"ignoreWarnings": false,
"lastModifiedDate": "2024-08-28T04:06:20.000Z",
"numberComponentErrors": 1,
"numberComponentsDeployed": 0,
"numberComponentsTotal": 1,
"numberTestErrors": 0,
"numberTestsCompleted": 0,
"numberTestsTotal": 0,
"rollbackOnError": true,
"runTestsEnabled": false,
"startDate": "2024-08-28T04:06:16.000Z",
"status": "Failed",
"success": false,
"files": [...]
},
"warnings": []
}
{
"status": 0,
"result": {
"checkOnly": false,
"completedDate": "2024-08-20T00:52:42.000Z",
"createdBy": "0052P000000K5Mw",
"createdByName": "Script User",
"createdDate": "2024-08-20T00:52:34.000Z",
"details": {
"componentFailures": [...],
"componentSuccesses": [...],
"runTestResult": {...}
},
"done": true,
"id": "0Af9p00000xxx",
"ignoreWarnings": false,
"lastModifiedDate": "2024-08-20T00:52:42.000Z",
"numberComponentErrors": 25,
"numberComponentsDeployed": 0,
"numberComponentsTotal": 25,
"numberTestErrors": 0,
"numberTestsCompleted": 0,
"numberTestsTotal": 0,
"rollbackOnError": true,
"runTestsEnabled": true,
"startDate": "2024-08-20T00:52:34.000Z",
"status": "Failed",
"success": false,
"files": [...]
},
"warnings": []
}
Would it be right to assume that status is 0 because the job is completed from the org? I'm also curious about which field is being returned to the terminal to be parsed by the script.
No, we set the status
key in the JSON output of any sf
commands to the same exit code from the process:
here we set it to whatever process.exitCode
is (if number) or fallback to 0
:
https://github.com/salesforcecli/sf-plugins-core/blob/c61adc2093e035acac06b71322bac9fac13325bb/src/sfCommand.ts#L364
same with results but fallback to 1
:
https://github.com/salesforcecli/sf-plugins-core/blob/c61adc2093e035acac06b71322bac9fac13325bb/src/errorHandling.ts#L44
In the 2 JSON results you shared above I see the the org is returning "status": "Failed"
(which should make the CLI set exit code = 1).
I'll check our telemetry and see if I can find similar scenarios.
@cristiand391, it happened again on one of our pipelines running in an older container which is still using sfdx
(sfdx-cli version v7.194.1) commands which leads me to believe that the issue is not related to whether using sf
or sfdx
and Azure but as to how the API behaves. Are you aware of any API changes from Salesforce that may cause this issue?
it happened again on one of our pipelines running in an older container which is still using sfdx (sfdx-cli version v7.194.1) commands which leads me to believe that the issue is not related to whether using sf or sfdx and Azure but as to how the API behaves. Are you aware of any API changes from Salesforce that may cause this issue?
Nope, but for the CLI to exit with 0 the API should be returning "status": "Succeeded"
with a bad deploy...
If you can share the deploy ID of a deploy that failed but made sf
exit with code 0 we could look into what the API returned from our side (CLI telemetry isn't enough to link a deploy to a command exec).
Here's several deployment IDs that exited 0 and failed in the org:
Deployment in Org A - 0Af9p00000KNB7OCAX
Deployment in Org A - 0Af9p00000KP7ScCAL
Prod validation in Org B - 0AfOZ000000ZPun0AG (after the false positive was thrown, quick deployment failed with an error INVALID_ID_FIELD: Source validate did not run tests in the org
even though we triggered the tests)
Summary
On August 20, we noticed our pipelines are showing as successful but upon checking the deployment status, it reported error and should have failed the pipeline.
Steps To Reproduce
After replicating issue with similar variables (latest SF CLI version at that time which appears to be 2.56.4, components being deployed, tests being run), the issue no longer seem to persist and cannot be reproduced anymore.
Command used
sf project deploy start -d delta -o TargetOrg -l RunSpecifiedTests -t $(test_classes) -w 120 -c
Expected result
Failed deployments on pipelines should appear failed.
Actual result
Failed deployments showing up as succeeded.
Additional information
False positive deployment:
After replicating and getting the expected behavior:
System Information
Operating System Ubuntu 22.04.4 LTS
JSON