salesforcedx-vscode icon indicating copy to clipboard operation
salesforcedx-vscode copied to clipboard

"SFDX: Set a Default Org failed to run" even though the output shows it has true

Open raksh36 opened this issue 1 year ago • 11 comments

Summary

After the project loads, the default org shows an error

Steps To Reproduce:

  1. Authenticate against a sandbox using SFDX : Authorize an org
  2. After the credentials are entered we see the org value is set but the extension throws an error stating 'SFDX: Set a Default Org failed to run'. The output tab shows the result as Starting SFDX: Set a Default Org.

16:50:22.144 sfdx force:config:set defaultusername=dev4c === Set Config

Name Value Success ─────────────── ───── ─────── defaultusername dev4c true
16:50:54.78 sfdx force:config:set defaultusername=dev4c ended with exit code 1 3. When I try to check the Org contents on the org browser, it throws this error- 'SyntaxError: Unexpected end of JSON input' and metadata does not load.

Expected result

Default org should show as success and Org browser should display org metadata .

Actual result

Output tab throws the exit code as 1 when we set a default org. Org browser does not display any metadata and throws SyntaxError: Unexpected end of JSON input

Additional information

SyntaxError_UnexpectedEndOfJSONinput SFDX_Set a Default Org failed to run

Salesforce Extension Version in VS Code:

SFDX CLI Version: sfdx-cli/7.182.1 win32-x64 node-v18.12.1

OS and version: Windows 10 Enterprise. Version - 10.0.19044 Build 19044

raksh36 avatar Dec 28 '22 13:12 raksh36

Salesforce CLI Integration Extension version: v56.5.1

raksh36 avatar Dec 28 '22 13:12 raksh36

Hello! Could you please try updating to v56.14.0 and check if this is still an issue?

CristiCanizales avatar Jan 24 '23 18:01 CristiCanizales

CLI Integration extension upgraded to v56.14.0 and the problem still exists image image image

raksh36 avatar Jan 26 '23 15:01 raksh36

Hello! 🙂 Could you please tell me the type of the org? (Profesional, Enterprise, etc)

CristiCanizales avatar Jan 26 '23 15:01 CristiCanizales

Org type - Unlimited Edition

raksh36 avatar Jan 26 '23 16:01 raksh36

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

github-actions[bot] avatar Feb 03 '23 02:02 github-actions[bot]

Hello! 🙂 Could you please tell me the type of the org? (Profesional, Enterprise, etc)

Org type - Unlimited Edition

raksh36 avatar Feb 05 '23 12:02 raksh36

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

github-actions[bot] avatar Feb 13 '23 02:02 github-actions[bot]

Hi @raksh36 Sorry for the delay. So many issue so little time :) I've seen reports in the past where this kind of error occurs if there is an invalid zero byte json file in the the sfdx configuration directory. Can you check if there are any empty json files under the .sfdx dir? Ref

There are local configs for the project found in the .sfdx directory of your project and global configs found under ~/.sfdx

Another good sanity check is from that project directory are you able to run the cli command sfdx force:config:set defaultusername=dev4c

gbockus-sf avatar Feb 14 '23 18:02 gbockus-sf

Hi @gbockus-sf Running the above command listed as a sanity check throws a non-zero exit code error (Exit-code 1). But the output is shown as success - true Non-zero error

raksh36 avatar Feb 15 '23 14:02 raksh36

Hi @gbockus-sf is there a way where we can connect and try to debug this? For an existing project created an year ago, it manages to work fine when i switch the org to a particular instance (in this case stgbeta). This works only when i switch the org (which throws 'Unexpected end of JSON input' error) and restart VSCode. Strange behavior.

raksh36 avatar Feb 16 '23 11:02 raksh36