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: tolerate broken auth files (with warning) during readAll #869

Merged
merged 4 commits into from
Jun 26, 2023

Conversation

mshanemc
Copy link
Contributor

@mshanemc mshanemc commented Jun 22, 2023

What does this PR do?

errors were swallowed by the finally block in ConfigFile, so that's removed. Steve and I don't understand what that was solving, so this might re-expose additional errors that were being swallowed, since only ENOENT is handled.

It's probably not going to hurt reading Org files (orgAccessor is modified to only throw on JSON.parse errors and still return null for everything else.

also including #870 to get latest jsforce (NUTs seem to need this)

What issues does this PR fix or reference?

forcedotcom/cli#2066
@W-13039897@

@mshanemc mshanemc marked this pull request as ready for review June 22, 2023 15:48
cristiand391
cristiand391 previously approved these changes Jun 23, 2023
@cristiand391
Copy link
Member

QA notes:

  1. checkout PR
  2. link sfdx-core into plugin-org
  3. modify auth file, invalid json.

✅ get warning in stdout/json when json in auth file is invalid

➜  plugin-org git:(main) ./bin/dev org:list
Warning: The auth file for [email protected] is invalid.
Non-scratch orgs
=================================================================================================
|   ALIAS               USERNAME                              ORG ID             CONNECTED STATUS
| ─ ─────────────────── ───────────────────────────────────── ────────────────── ────────────────
...

➜  plugin-org git:(main) echo $?
0

➜  plugin-org git:(main) ./bin/dev org:list --json | jq .warnings
[
  "The auth file for [email protected] is invalid."
]

before it would throw an error when an auth file was invalid.

🟡 don't get warning when using org flags.

➜  plugin-org git:(main) ./bin/dev org:display -o [email protected]
Error (1): Parsing --target-org
        No authorization information found for [email protected].
See more help with --help

Is it possible to make the Org class throw the invalid auth file warning before or does it happen after this validation is done?

@cristiand391
Copy link
Member

QA update:

🟡 don't get warning when using org flags.

🟢 with alias and invalid auth file

➜  plugin-org git:(main) ./bin/dev org:display -o na40
Error (1): Parsing --target-org
        Parse error in file /Users/cdominguez/.sfdx/[email protected] on line 1
"accessToken": "*****
See more help with --help

🟢 with alias to a non-existent username

➜  plugin-org git:(main) ./bin/dev org:display -o lalala
Error (1): Parsing --target-org
        No authorization information found for lalala.
See more help with --help

🟢 json error contains stack trace, shows auth file path.

@cristiand391 cristiand391 merged commit 4cea657 into main Jun 26, 2023
@cristiand391 cristiand391 deleted the sm/tolerate-broken-auth-files branch June 26, 2023 20:05
@cristiand391 cristiand391 mentioned this pull request Jun 26, 2023
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.

2 participants