Skip to content

[BUG]: Default Validate Test Level isn't set to RunSpecifiedTests when passing --tests #3679

Open

Description

@mcarvin8

Before You Submit

  • I'm using the latest version of Salesforce CLI
  • I've searched the existing issues
  • I've run sf doctor to diagnose common issues

Related Issue

No response

Command

sf project deploy validate

Org Type

Production

Did this work before?

Not sure

Last Working Version

No response

Summary

sf project deploy validate overrides the shared testLevelFlag default (src/utils/flags.ts), which sets --test-level to RunSpecifiedTests when --tests is passed, with a static default: TestLevel.RunLocalTests.

As a result, sf project deploy validate --tests MyTest (without --test-level) sent runTests=[MyTest] with testLevel=RunLocalTests, and the Metadata API rejected the request:

INVALID_OPERATION: runTests can only be used with a testLevel of RunSpecifiedTests

This doesn't affect sf project deploy start, which successfully sets test level to RunSpecifiedTests when you pass it --tests. This request is to align this behavior with the validate command.

I created the PR for this fix last month in plugin-deploy-retrieve: salesforcecli/plugin-deploy-retrieve#1650 (Markdown changes were approved but pending code changes)

Repository to Reproduce

No response

Steps to reproduce

  1. Run sf project deploy validate with --tests but no explicit --test-level set.

Expected Result

When --tests are provided to sf project deploy validate, the test level is set to RunSpecifiedTests implicitly.

Actual Result

When --tests are provided to sf project deploy validate, the test level is set to RunAllLocalTestsand the validation fails with an INVALID_OPERATION.

Error Message

INVALID_OPERATION: runTests can only be used with a testLevel of RunSpecifiedTests

System Information

{
  "architecture": "linux-x64",
  "cliVersion": "@salesforce/cli/2.156.8",
  "nodeVersion": "node-v24.22.1",
  "osVersion": "Linux 5.14.0-687.60.1.el9_8.x86_64",
  "rootPath": "/usr/local/sf",
  "shell": "bash",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 4.0.5 (core)",
    "@oclif/plugin-commands 5.0.5 (core)",
    "@oclif/plugin-help 7.0.5 (core)",
    "@oclif/plugin-not-found 4.0.5 (core)",
    "@oclif/plugin-plugins 7.0.10 (core)",
    "@oclif/plugin-search 2.0.5 (core)",
    "@oclif/plugin-update 5.0.8 (core)",
    "@oclif/plugin-version 3.0.6 (core)",
    "@oclif/plugin-warn-if-update-available 4.0.4 (core)",
    "@oclif/plugin-which 4.0.5 (core)",
    "@salesforce/cli 2.156.8 (core)",
    "agent 2.2.3 (core)",
    "apex 4.4.4 (core)",
    "api 2.0.19 (core)",
    "auth 6.0.0 (core)",
    "data 5.1.19 (core)",
    "deploy-retrieve 4.2.18 (core)",
    "info 4.0.18 (core)",
    "limits 4.0.6 (core)",
    "marketplace 2.0.18 (core)",
    "org 7.0.2 (core)",
    "packaging 3.0.14 (core)",
    "schema 4.0.12 (core)",
    "settings 3.0.17 (core)",
    "sobject 2.0.13 (core)",
    "telemetry 4.2.1 (core)",
    "templates 57.4.8 (core)",
    "trust 4.0.23 (core)",
    "user 6.0.3 (core)",
    "apex-code-coverage-transformer 3.1.12 (user)",
    "apextestlist 1.15.4 (user)",
    "sfdx-git-delta 7.6.0 (user)"
  ]
}

Additional Information

See the fix in PR salesforcecli/plugin-deploy-retrieve#1650

Screenshots or Log Files

No response

Activity

  1. github-actions commented on Nov 4, 2026

    @github-actions

    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.

  2. added
    validatedVersion information for this issue has been validated
    on Nov 4, 2026
  3. WillieRuemmele commented on Nov 4, 2026

    @WillieRuemmele
    Member

    Hi @mcarvin8 - thanks for the find, we'll fix it

  4. added
    bugIssue or pull request that identifies or fixes a bug
    and removed
    investigatingWe're actively investigating this issue
    on Nov 4, 2026
  5. git2gus commented on Nov 4, 2026

    @git2gus

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue or pull request that identifies or fixes a bugvalidatedVersion information for this issue has been validated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions