forcedotcom / cli

Salesforce CLI
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/
BSD 3-Clause "New" or "Revised" License
491 stars 78 forks source link

Command `sf apex run test` fails randomly with error "Unknown error in Apex Library: Error authenticating with JWT" #2890

Closed corentindoctolib closed 3 months ago

corentindoctolib commented 4 months ago

Summary

An error occur randomly when running the command sf apex run test --test-level RunLocalTests on a Scratch org : Unknown error in Apex Library: Error authenticating with JWT. This seems to happen in 25% of executions.

See error below :

image

And sometimes (75%), the execution is successful :

image

Steps To Reproduce

Private repo, sorry.

Expected result

The Apex tests are executed without loosing the auth. to the Scratch Org.

Actual result

Sometimes, an error occur : Unknown error in Apex Library: Error authenticating with JWT.

System Information

{
  "architecture": "win32-x64",
  "cliVersion": "@salesforce/cli/2.42.6",
  "nodeVersion": "node-v20.11.1",
  "osVersion": "Windows_NT 10.0.22621",
  "rootPath": "C:\\Users\\corentin.romilly\\AppData\\Roaming\\npm\\node_modules\\@salesforce\\cli",
  "shell": "cmd.exe",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.0.18 (core)",
    "@oclif/plugin-commands 3.3.4 (core)",
    "@oclif/plugin-help 6.0.22 (core)",
    "@oclif/plugin-not-found 3.1.9 (core)",
    "@oclif/plugin-plugins 5.0.21 (core)",
    "@oclif/plugin-search 1.0.24 (core)",
    "@oclif/plugin-update 4.2.12 (core)",
    "@oclif/plugin-version 2.1.2 (core)",
    "@oclif/plugin-warn-if-update-available 3.0.19 (core)",
    "@oclif/plugin-which 3.1.10 (core)",
    "@salesforce/cli 2.42.6 (core)",
    "apex 3.1.11 (core)",
    "auth 3.6.11 (core)",
    "data 3.3.5 (core)",
    "deploy-retrieve 3.6.14 (core)",
    "info 3.2.8 (core)",
    "limits 3.3.7 (core)",
    "marketplace 1.2.5 (core)",
    "org 4.1.10 (core)",
    "packaging 2.4.4 (core)",
    "schema 3.3.6 (core)",
    "settings 2.2.6 (core)",
    "signups 2.0.28 (user) published 87 days ago (Sun Mar 03 2024) (latest is 2.3.5)",
    "sobject 1.4.2 (core)",
    "source 3.3.12 (core)",
    "telemetry 3.3.7 (core)",
    "templates 56.2.7 (core)",
    "trust 3.6.11 (core)",
    "user 3.5.8 (core)"
  ]
}

Additional information

github-actions[bot] commented 4 months ago

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.

ebertineau commented 4 months ago

same issue here

ybelbaki commented 4 months ago

same here

MarcoLePolo commented 4 months ago

I have the same issue

cristiand391 commented 4 months ago

a few questions:

1) Are these failures more frequent on CI where new scratch orgs are created? the screenshot looks like it's from CI. 2) if so, how do you authenticate to scratch orgs?

related: https://github.com/forcedotcom/cli/issues/1640#issuecomment-1286961544

the comment from above refers to this failure when trying to auth to a new scratch org using its creds, but this same flow happens when refreshing an expired access token.

Also, can you provide enable debug logs (pass --dev-debug flag) and share the results from the failure?

github-actions[bot] commented 3 months ago

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.