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

"sf api request rest" does not refresh session token when required #3176

Closed
aidan-harding opened this issue Jan 15, 2025 · 4 comments
Closed
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue validated Version information for this issue has been validated

Comments

@aidan-harding
Copy link

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 doctor command 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

When I run sf api request rest '/services/data/v60.0/' --method GET, it works great most of the time.

But if the CLI's access token has expired and need to be refreshed, this command just fails instead of refreshing the token.

Obviously, I know that this is a beta command, but it'll be good to know it's on the issue list for when this command becomes fully released.

Steps To Reproduce

In a project where the access token has expired, run sf api request rest '/services/data/v60.0/' --method GET before running any other CLI command.

This will fail, if you run another CLI command against your org, then retry the api request, it will succeed.

Expected result

CLI returns the API description

{
  "metadata": "/services/data/v60.0/metadata",
  "eclair": "/services/data/v60.0/eclair",
  "folders": "/services/data/v60.0/folders",
  "jsonxform": "/services/data/v60.0/jsonxform",
  "appMenu": "/services/data/v60.0/appMenu",
...

Actual result

Session error returned:

[
  {
    "message": "Session expired or invalid",
    "errorCode": "INVALID_SESSION_ID"
  }
]

Additional information

System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.71.6",
  "nodeVersion": "node-v22.12.0",
  "osVersion": "Darwin 23.6.0",
  "rootPath": "/Users/aidan/.local/share/sf/client/2.71.6-df87f59",
  "shell": "zsh",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.14 (core)",
    "@oclif/plugin-commands 4.1.14 (core)",
    "@oclif/plugin-help 6.2.19 (core)",
    "@oclif/plugin-not-found 3.2.31 (core)",
    "@oclif/plugin-plugins 5.4.22 (core)",
    "@oclif/plugin-search 1.2.17 (core)",
    "@oclif/plugin-update 4.6.18 (core)",
    "@oclif/plugin-version 2.2.18 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.28 (core)",
    "@oclif/plugin-which 3.2.21 (core)",
    "@processity/cli-performance-testing 0.0.9 (user) published 125 days ago (Wed Sep 11 2024)",
    "@salesforce/cli 2.71.6 (core)",
    "apex 3.6.8 (core)",
    "api 1.3.2 (core)",
    "auth 3.6.82 (core)",
    "community 3.3.7 (user) published 32 days ago (Sat Dec 14 2024) (latest is 3.3.8)",
    "data 3.13.5 (core)",
    "deploy-retrieve 3.16.0 (core)",
    "info 3.4.29 (core)",
    "limits 3.3.43 (core)",
    "marketplace 1.3.7 (core)",
    "org 5.2.11 (core)",
    "packaging 2.9.7 (core)",
    "schema 3.3.45 (core)",
    "settings 2.4.9 (core)",
    "sobject 1.4.46 (core)",
    "telemetry 3.6.27 (core)",
    "templates 56.3.34 (core)",
    "trust 3.7.51 (core)",
    "user 3.6.5 (core)",
    "@salesforce/sfdx-scanner 4.7.0 (user) published 77 days ago (Tue Oct 29 2024) (latest is 4.8.0)"
  ]
}
@aidan-harding aidan-harding added the investigating We're actively investigating this issue label Jan 15, 2025
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 Jan 15, 2025
@iowillhoit iowillhoit added the bug Issue or pull request that identifies or fixes a bug label Jan 15, 2025
Copy link

git2gus bot commented Jan 15, 2025

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

@iowillhoit
Copy link
Contributor

Thanks @aidan-harding, we'll take a look at this!

@cristiand391
Copy link
Member

this was fixed in sf v2.74.6:
https://github.com/forcedotcom/cli/tree/main/releasenotes/#2746-jan-29-2025-stable

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 investigating We're actively investigating this issue validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

3 participants