Skip to content

Using --flags-dir on (third-party) sf plugins does not work #3493

@amtrack

Description

@amtrack

Summary

While I can successfully use the --flags-dir on core plugins, it does not work anymore with my sf plugin.
The --dev-debug shows the preparse hook was run in both cases, but the flag values are not set in my sf plugin sfdx-plugin-source-read and this Minimal Reproducible Example (MRE):

myflags/metadata:

Profile:Admin
Profile:Standard

Using the official sf project retrieve start:

sf project retrieve start --flags-dir myflags --dev-debug
# DEBUG (sf:oclif:@salesforce/cli:hooks:preparse): Returning argv: --flags-dir myflags --metadata Profile:Admin --metadata Profile:Standard

Using my plugin sf crud-mdapi read: flags.metadata is undefined

sf crud-mdapi read --flags-dir myflags --dev-debug
# DEBUG (sf:oclif:@salesforce/cli:hooks:preparse): Returning argv: --flags-dir myflags --metadata Profile:Admin --metadata Profile:Standard

Steps To Reproduce

I've created a Minimal Reproducible Example (MRE): https://github.com/mdapi-issues/mre-sf-plugin-flags-dir

Expected result

The flag values should be set correctly when using --flags-dir.

Actual result

The flag values are set to the default value.

Additional information

Here is the initial bug report for my sf plugin: amtrack/sfdx-plugin-source-read#159

System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.120.3",
  "nodeVersion": "node-v24.13.0",
  "osVersion": "Darwin 25.2.0",
  "rootPath": "/Users/john.doe/.local/lib/node_modules/@salesforce/cli",
  "shell": "zsh",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.39 (core)",
    "@oclif/plugin-commands 4.1.38 (core)",
    "@oclif/plugin-help 6.2.36 (core)",
    "@oclif/plugin-not-found 3.2.73 (core)",
    "@oclif/plugin-plugins 5.4.54 (core)",
    "@oclif/plugin-search 1.2.36 (core)",
    "@oclif/plugin-update 4.7.16 (core)",
    "@oclif/plugin-version 2.2.36 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.54 (core)",
    "@oclif/plugin-which 3.2.42 (core)",
    "@salesforce/cli 2.120.3 (core)",
    "agent 1.26.5 (core)",
    "apex 3.9.5 (core)",
    "api 1.3.7 (core)",
    "auth 4.1.2 (core)",
    "data 4.0.67 (core)",
    "deploy-retrieve 3.24.7 (core)",
    "info 3.4.100 (core)",
    "limits 3.3.74 (core)",
    "marketplace 1.3.8 (core)",
    "org 5.9.59 (core)",
    "packaging 2.24.7 (core)",
    "schema 3.3.90 (core)",
    "settings 2.4.54 (core)",
    "sobject 1.4.81 (core)",
    "telemetry 3.6.71 (core)",
    "templates 56.4.2 (core)",
    "trust 3.7.113 (core)",
    "user 3.6.46 (core)"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    investigatingWe're actively investigating this issuevalidatedVersion 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