Bug: "sf project deploy start" parses --test-level incorrectly when combined with multiple tests via -t
Note Before you submit your issue, make sure that:
- You're using the latest version of Salesforce CLI.
- You've searched both open and closed issues for related posts.
- You've used the
doctorcommand to diagnose common issues.- You understand that GitHub Issues don't adhere to any agreement or SLA.
- If you require immediate assistance, use official channels such as Salesforce Customer Support.
Summary
I am encountering a parsing error when running sf project deploy start. I am trying to run specified tests using -l RunSpecifiedTests followed by a space-separated list of tests using -t.
The CLI seems to interpret the -t flag and the subsequent test names as part of the string value for the -l (test-level) flag, causing a validation error
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 generateor fork dreamhouse-lwc.- Provide detailed step-by-step instructions on how to reproduce the issue.
[!TIP] use
sf doctor --create-issueto automatically fill the required information
Steps To Reproduce Execute the following command (passing multiple tests via command line or variable):
Bash
sf project deploy start -d force-app/main/default -o TARGET_ORG -l RunSpecifiedTests -t TestClass1 TestClass2 TestClass3 TestClass4 TestClass5 --dry-run -w 60 Note: This often happens when passing the flags via a shell variable that is improperly quoted during execution.
Expected result The command should accept RunSpecifiedTests as the value for -l and then process the list of tests provided after -t separately.
Actual result The command fails immediately with an argument validation error. It appears to be reading the entire string after -l as a single argument including the test names.
Error Output:
Plaintext
Error (1): Expected --test-level= RunSpecifiedTests -t TestClass1 TestClass2 TestClass3 TestClass4 TestClass5 --dry-run to be one of: NoTestRun, RunSpecifiedTests, RunLocalTests, RunAllTestsInOrg
System Information
bash 2.109.7PASTE_VERSION_OUTPUT_HERE
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 @EmilioCarrelon99 :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:
- Make sure you've provided detailed steps to reproduce your issue.
- A repository that clearly demonstrates the bug is ideal.
- Make sure you've installed the latest version of Salesforce CLI. (docs)
- Better yet, try the
rcornightlyversions. (docs)
- Better yet, try the
- Try running the
doctorcommand to diagnose common issues. - Search GitHub for existing related issues.
Thank you!
"architecture": "wsl-x64", "cliVersion": "@salesforce/cli/2.109.7", "nodeVersion": "node-v24.7.0", "osVersion": "Linux 6.1.91.1-microsoft-standard", "rootPath": "/opt/bitnami/node/lib/node_modules/@salesforce/cli", "shell": "bash", "pluginVersions": [ "@lidl1/specific-tests-plugin 1.2.2 (link) /azp/_work/5/s", "@oclif/plugin-autocomplete 3.2.35 (core)", "@oclif/plugin-commands 4.1.33 (core)", "@oclif/plugin-help 6.2.33 (core)", "@oclif/plugin-not-found 3.2.68 (core)", "@oclif/plugin-plugins 5.4.48 (core)", "@oclif/plugin-search 1.2.32 (core)", "@oclif/plugin-update 4.7.8 (core)", "@oclif/plugin-version 2.2.33 (core)", "@oclif/plugin-warn-if-update-available 3.1.48 (core)", "@oclif/plugin-which 3.2.40 (core)", "@salesforce/cli 2.109.7 (core)", "agent 1.24.13 (core)", "apex 3.8.3 (core)", "api 1.3.3 (core)", "auth 3.9.17 (core)", "data 4.0.58 (core)", "deploy-retrieve 3.23.3 (core)", "info 3.4.88 (core)", "limits 3.3.67 (core)", "marketplace 1.3.8 (core)", "org 5.9.32 (core)", "packaging 2.20.5 (core)", "schema 3.3.82 (core)", "settings 2.4.48 (core)", "sobject 1.4.73 (core)", "telemetry 3.6.58 (core)", "templates 56.3.65 (core)", "trust 3.7.113 (core)", "user 3.6.38 (core)", "sfdx-git-delta 6.0.0 (user) published 308 days ago (Tue Jan 07 2025) (latest is 6.23.0)" ] }
Hello @EmilioCarrelon99 :wave: None of the versions of sf you shared match the latest release.
Shared: 2.109.7
Latest: 2.111.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
"architecture": "wsl-x64", "cliVersion": "@salesforce/cli/2.111.7", "nodeVersion": "node-v24.7.0", "osVersion": "Linux 6.1.91.1-microsoft-standard", "rootPath": "/opt/bitnami/node/lib/node_modules/@salesforce/cli", "shell": "bash", "pluginVersions": [ "@lidl1/specific-tests-plugin 1.2.2 (link) /azp/_work/1/s", "@oclif/plugin-autocomplete 3.2.38 (core)", "@oclif/plugin-commands 4.1.37 (core)", "@oclif/plugin-help 6.2.34 (core)", "@oclif/plugin-not-found 3.2.71 (core)", "@oclif/plugin-plugins 5.4.52 (core)", "@oclif/plugin-search 1.2.34 (core)", "@oclif/plugin-update 4.7.13 (core)", "@oclif/plugin-version 2.2.35 (core)", "@oclif/plugin-warn-if-update-available 3.1.51 (core)", "@oclif/plugin-which 3.2.42 (core)", "@salesforce/cli 2.111.7 (core)", "agent 1.24.21 (core)", "apex 3.8.5 (core)", "api 1.3.3 (core)", "auth 3.9.17 (core)", "data 4.0.59 (core)", "deploy-retrieve 3.23.12 (core)", "info 3.4.95 (core)", "limits 3.3.70 (core)", "marketplace 1.3.8 (core)", "org 5.9.41 (core)", "packaging 2.23.0 (core)", "schema 3.3.86 (core)", "settings 2.4.50 (core)", "sobject 1.4.77 (core)", "telemetry 3.6.62 (core)", "templates 56.3.69 (core)", "trust 3.7.113 (core)", "user 3.6.38 (core)", "sfdx-git-delta 6.0.0 (user) published 308 days ago (Tue Jan 07 2025) (latest is 6.23.0)" ] }
Hi @EmilioCarrelon99 I was not able to reproduce the issue.
Can you update the CLI to latest and run the command again adding --dev-debug flag?
hey, sorry for the late reply!
Note: This often happens when passing the flags via a shell variable that is improperly quoted during execution.
then it is a quoting issue, the script seems to be passing the whole env var as a string and the CLI parsing treats it as a flag value.