Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REGRESSION: CLI prompts for interaction in non-TTY environment in 2.30.7 (doesn't in 2.29.5 and older) #2739

Closed
daveespo opened this issue Feb 22, 2024 · 6 comments
Labels
bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated

Comments

@daveespo
Copy link

Summary

The CLI has historically not prompted for user interaction in non-TTY environments. Starting in 2.30.7 (next week's release candidate), the CLI will prompt and wait for input before timing out and returning a non-zero error code. Prior versions would exit immediately and return a zero status code.

It's debatable whether this was a feature or a bug -- but there is definitely a change in behavior here that isn't in the release notes.

Steps To Reproduce

On 2.29.5

env - HOME="$HOME" /bin/sh -c "~/sf/bin/sf a b c && echo $?" </dev/null
 ›   Warning: a b c is not a sf command.
Did you mean help? [y/n]: 0

On 2.30.5

env - HOME="$HOME" /bin/sh -c "~/sf-rc/bin/sf a b c && echo $?" </dev/null
 ›   Warning: a b c is not a sf command.
Did you mean help? [y/n]:

 ›   Error: Run sf help for a list of available commands.

Note The command waited for 5 seconds before it finally generated the error. Additionally, it exited with a non-zero status code (127) compared with the zero (0) exit code when run on 2.29.5

Expected result

Prior behavior was to exit immediately and return a zero exit code

Actual result

Command waits 5 seconds for user interaction then exits with 127 exit code

System Information

{
  "architecture": "wsl-x64",
  "cliVersion": "@salesforce/cli/2.30.7",
  "nodeVersion": "node-v20.11.0",
  "osVersion": "Linux 5.10.102.1-microsoft-standard-WSL2",
  "rootPath": "/home/esposito/sf-rc/sf",
  "shell": "bash",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.0.9 (core)",
    "@oclif/plugin-commands 3.1.4 (core)",
    "@oclif/plugin-help 6.0.13 (core)",
    "@oclif/plugin-not-found 3.0.11 (core)",
    "@oclif/plugin-plugins 4.2.5 (core)",
    "@oclif/plugin-search 1.0.16 (core)",
    "@oclif/plugin-update 4.1.13 (core)",
    "@oclif/plugin-version 2.0.12 (core)",
    "@oclif/plugin-warn-if-update-available 3.0.12 (core)",
    "@oclif/plugin-which 3.1.0 (core)",
    "@salesforce/cli 2.30.7 (core)",
    "apex 3.0.25 (core)",
    "auth 3.3.13 (core)",
    "data 3.1.1 (core)",
    "deploy-retrieve 3.2.16 (core)",
    "info 3.0.27 (core)",
    "limits 3.1.10 (core)",
    "marketplace 1.0.25 (core)",
    "org 3.3.14 (core)",
    "packaging 2.1.10 (core)",
    "schema 3.1.3 (core)",
    "settings 2.0.27 (core)",
    "sobject 1.1.13 (core)",
    "source 3.1.15 (core)",
    "telemetry 3.1.13 (core)",
    "templates 56.0.16 (core)",
    "trust 3.3.10 (core)",
    "user 3.2.11 (core)",
    "sfdmu 4.32.0 (user)"
  ]
}
@daveespo daveespo added the investigating We're actively investigating this issue label Feb 22, 2024
Copy link

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 github-actions bot added the validated Version information for this issue has been validated label Feb 22, 2024
@mdonnalley mdonnalley added bug Issue or pull request that identifies or fixes a bug and removed investigating We're actively investigating this issue labels Feb 22, 2024
Copy link

git2gus bot commented Feb 22, 2024

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

@iowillhoit
Copy link
Contributor

Hey @daveespo,
@mdonnalley was able to get a fix in for this. I kicked off a nightly with this change, could you install it (2.31.1) and see if it fixes your issue? If it does, I will patch the rc.

@daveespo
Copy link
Author

@iowillhoit -- yep, on @salesforce/cli/2.31.1 linux-x64 node-v20.11.0 the build passes cleanly (doesn't prompt for interaction and exits with error code 0)

Thank you @mdonnalley for the quick turnaround

And FTR, I do think the current behavior is a bug .. the fact that trying to run an invalid command returns a 0 error code in a non-TTY environment (when it returns a 127 in TTY), is unexpected. But if you're going to change that in the future, please make sure it hits the release notes with a preparation period to let people know it's coming.

@daveespo
Copy link
Author

@mdonnalley -- any chance this code regressed in @salesforce/cli/2.35.6 (today's RC build)?

Yesterday's RC (@salesforce/cli/2.34.7) returned exit code 0 for the above example .. today it's returning 127

CC @mshanemc

@mdonnalley
Copy link
Contributor

@daveespo Yes, that's the expected behavior now.

Checkout the release notes for the 2.35.6

FIX: If you run a non-existent command with "closed stdin" (i.e. you specify <&- or < /dev/null after the command), Salesforce CLI now waits 10 seconds after prompting for a matching command, and then returns the appropriate error exit code. Previously it returned a 0 exit code. [oclif GitHub issue https://github.com/oclif/plugin-not-found/issues/266, oclif plugin-not-found PR https://github.com/oclif/plugin-not-found/pull/566)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

4 participants