Summary
When using TestSession.create for NUTs (development of a custom CLI plugin), the test setup occasionally fails. I have not been able to reliably reproduce this, since the same commit may have worked yesterday and fails today.
Steps To Reproduce
See the commit history of this PR: https://github.com/j-schreiber/js-sf-cli-security-audit/pull/24/commits
Due to the nature of the problem, I do not know how to describe how to reproduce it. Here are my thoughts on how this can be reproduced
The NUTs fail with this SfError, that originates in AuthInfo.create.
{
"name": "NamedOrgNotFoundError",
"message": "No authorization information found for ***.",
"exitCode": 1,
"context": "OrgCreateScratch",
"stack": "NamedOrgNotFoundError: No authorization information found for ***.\n at SfCommandError.from (file:///opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/sf-plugins-core/lib/SfCommandError.js:48:16)\n at OrgCreateScratch.catch (file:///opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/sf-plugins-core/lib/sfCommand.js:332:47)\n at OrgCreateScratch._run (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/command.js:186:29)\n at async Config.runCommand (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:456:25)\n at async run (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/main.js:97:16)\n at async file:///opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/bin/run.js:15:1",
"cause": "SfError [NamedOrgNotFoundError]: No authorization information found for ***.\n at Messages.createError (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/messages.js:448:16)\n at AuthInfo.loadDecryptedAuthFromConfig (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/authInfo.js:772:28)\n at AuthInfo.initAuthOptions (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/authInfo.js:722:53)\n at async AuthInfo.init (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/authInfo.js:693:13)\n at async AuthInfo.create (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/kit/lib/creatable.js:66:9)\n at async authorizeScratchOrg (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/scratchOrgInfoApi.js:177:20)\n at async scratchOrgCreate (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/scratchOrgCreate.js:176:32)\n at async OrgCreateScratch.run (file:///opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/lib/commands/org/create/scratch.js:214:72)\n at async OrgCreateScratch._run (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/command.js:182:22)\n at async Config.runCommand (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:456:25) {\n actions: undefined,\n exitCode: 1,\n context: undefined,\n data: undefined,\n cause: undefined\n}",
"warnings": [],
"code": "NamedOrgNotFoundError",
"status": 1,
"commandName": "OrgCreateScratch"
}
- I verified that the DevHub is successfully authenticated - with
TESTKIT_AUTH_URL and TESTKIT_JWT_KEY
- I can see in the login history of my CI user, that GitHub Actions successfully authenticates
- I verified on my DevHub, that scratch orgs are successfully created.
- The same overall setup (library versions, env variables) worked 24 hours earlier
From my own investigation, it looks like StateAggregator from salesforce/sfdx-core fails to return the org credentials. The error happens here: loadDecryptedAuthFromConfig
Unfortunately, sf doctor is not available in the CI environment, since I do not control the workflow.
Expected result
When the DevHub credentials are valid, TestSession.create can successfully access the AuthInfo and create a scratch org. It then proceeds to run NUTs.
Actual result
TestSession fails with an SfError that hints towards a problem reading the authinfo from ~./sfdx
The test aborts because before all hook fails and no NUTs are executed.
A test org is created on the DevHub, but the CLI cannot complete the process.
Additional information
Some of the created scratch orgs that were created, even though "createScratchOrg" throws an error
System Information
Github runner, ubuntu-latest together with Salesforce-managed NUTs workflow: https://github.com/salesforcecli/github-workflows/blob/main/.github/workflows/nut.yml
NUT workflow uses the nightly build 2.121.3
Summary
When using
TestSession.createfor NUTs (development of a custom CLI plugin), the test setup occasionally fails. I have not been able to reliably reproduce this, since the same commit may have worked yesterday and fails today.Steps To Reproduce
See the commit history of this PR: https://github.com/j-schreiber/js-sf-cli-security-audit/pull/24/commits
Due to the nature of the problem, I do not know how to describe how to reproduce it. Here are my thoughts on how this can be reproduced
The NUTs fail with this
SfError, that originates inAuthInfo.create.{ "name": "NamedOrgNotFoundError", "message": "No authorization information found for ***.", "exitCode": 1, "context": "OrgCreateScratch", "stack": "NamedOrgNotFoundError: No authorization information found for ***.\n at SfCommandError.from (file:///opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/sf-plugins-core/lib/SfCommandError.js:48:16)\n at OrgCreateScratch.catch (file:///opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/sf-plugins-core/lib/sfCommand.js:332:47)\n at OrgCreateScratch._run (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/command.js:186:29)\n at async Config.runCommand (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:456:25)\n at async run (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/main.js:97:16)\n at async file:///opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/bin/run.js:15:1", "cause": "SfError [NamedOrgNotFoundError]: No authorization information found for ***.\n at Messages.createError (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/messages.js:448:16)\n at AuthInfo.loadDecryptedAuthFromConfig (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/authInfo.js:772:28)\n at AuthInfo.initAuthOptions (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/authInfo.js:722:53)\n at async AuthInfo.init (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/authInfo.js:693:13)\n at async AuthInfo.create (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/kit/lib/creatable.js:66:9)\n at async authorizeScratchOrg (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/scratchOrgInfoApi.js:177:20)\n at async scratchOrgCreate (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/node_modules/@salesforce/core/lib/org/scratchOrgCreate.js:176:32)\n at async OrgCreateScratch.run (file:///opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-org/lib/commands/org/create/scratch.js:214:72)\n at async OrgCreateScratch._run (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/command.js:182:22)\n at async Config.runCommand (/opt/hostedtoolcache/node/24.13.0/x64/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:456:25) {\n actions: undefined,\n exitCode: 1,\n context: undefined,\n data: undefined,\n cause: undefined\n}", "warnings": [], "code": "NamedOrgNotFoundError", "status": 1, "commandName": "OrgCreateScratch" }TESTKIT_AUTH_URLandTESTKIT_JWT_KEYFrom my own investigation, it looks like
StateAggregatorfromsalesforce/sfdx-corefails to return the org credentials. The error happens here:loadDecryptedAuthFromConfigUnfortunately,
sf doctoris not available in the CI environment, since I do not control the workflow.Expected result
When the DevHub credentials are valid,
TestSession.createcan successfully access the AuthInfo and create a scratch org. It then proceeds to run NUTs.Actual result
TestSession fails with an
SfErrorthat hints towards a problem reading the authinfo from~./sfdxThe test aborts because
before allhook fails and no NUTs are executed.A test org is created on the DevHub, but the CLI cannot complete the process.
Additional information
Some of the created scratch orgs that were created, even though "createScratchOrg" throws an error
System Information
Github runner,
ubuntu-latesttogether with Salesforce-managed NUTs workflow: https://github.com/salesforcecli/github-workflows/blob/main/.github/workflows/nut.ymlNUT workflow uses the nightly build 2.121.3