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

fix: handle alias file with no orgs prop #969

Merged
merged 2 commits into from
Oct 26, 2023
Merged

Conversation

cristiand391
Copy link
Member

@cristiand391 cristiand391 commented Oct 25, 2023

What does this PR do?

makes the alias accessor handle alias files that don't have the orgs property (we got 2 reports happening where they get a alias file with {}` as the content, should also fix users on the old key:value alias file format).

repro:

write {} to your alias file (~/.sfdx/alias.json)
run SF_ENV=development sf alias list, see error

then if you link this branch of core into plugin-settings, with the same alias file you shouldn't get the error.

expected

sfdx-core handles bad alias file, returns "no alias found"

actual result

*** Internal Diagnostic ***

TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at fileContentsRawToAliasStore (/Users/cdominguez/.nvm/versions/node/v18.17.0/lib/node_modules/@salesforce/c
li/node_modules/@salesforce/core/lib/stateAggregator/accessors/aliasAccessor.js:245:27)
    at AliasAccessor.readFileToAliasStore (/Users/cdominguez/.nvm/versions/node/v18.17.0/lib/node_modules/@sales
force/cli/node_modules/@salesforce/core/lib/stateAggregator/accessors/aliasAccessor.js:187:31)
    at async AliasAccessor.init (/Users/cdominguez/.nvm/versions/node/v18.17.0/lib/node_modules/@salesforce/cli/
node_modules/@salesforce/core/lib/stateAggregator/accessors/aliasAccessor.js:176:9)
    at async AliasAccessor.create (/Users/cdominguez/.nvm/versions/node/v18.17.0/lib/node_modules/@salesforce/cl
i/node_modules/@salesforce/kit/lib/creatable.js:57:9)
    at async StateAggregator.init (/Users/cdominguez/.nvm/versions/node/v18.17.0/lib/node_modules/@salesforce/cl
i/node_modules/@salesforce/core/lib/stateAggregator/stateAggregator.js:40:24)
    at async StateAggregator.create (/Users/cdominguez/.nvm/versions/node/v18.17.0/lib/node_modules/@salesforce/
cli/node_modules/@salesforce/kit/lib/creatable.js:57:9)
    at async StateAggregator.getInstance (/Users/cdominguez/.nvm/versions/node/v18.17.0/lib/node_modules/@salesf
orce/cli/node_modules/@salesforce/core/lib/stateAggregator/stateAggregator.js:24:66)
    at async AliasList.run (/Users/cdominguez/.nvm/versions/node/v18.17.0/lib/node_modules/@salesforce/cli/node_
modules/@salesforce/plugin-settings/lib/commands/alias/list.js:17:33)
    at async AliasList._run (/Users/cdominguez/.nvm/versions/node/v18.17.0/lib/node_modules/@salesforce/cli/node
_modules/@salesforce/plugin-settings/node_modules/@oclif/core/lib/command.js:117:22)
******

What issues does this PR fix or reference?

@W-14365013@

Co-authored-by: Shane McLaughlin <shane.mclaughlin@salesforce.com>
@mshanemc mshanemc merged commit 55a7f3d into main Oct 26, 2023
31 checks passed
@mshanemc mshanemc deleted the cd/handle-alias-file-no-orgs branch October 26, 2023 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants