salesforcedx-vscode
salesforcedx-vscode copied to clipboard
"SFDX: Set a Default Org failed to run" even though the output shows it has true
Summary
After the project loads, the default org shows an error
Steps To Reproduce:
- Authenticate against a sandbox using SFDX : Authorize an org
- 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
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
Salesforce CLI Integration Extension version: v56.5.1
Hello! Could you please try updating to v56.14.0 and check if this is still an issue?
CLI Integration extension upgraded to v56.14.0 and the problem still exists
Hello! 🙂 Could you please tell me the type of the org? (Profesional, Enterprise, etc)
Org type - Unlimited Edition
This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.
Hello! 🙂 Could you please tell me the type of the org? (Profesional, Enterprise, etc)
Org type - Unlimited Edition
This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.
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
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
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.