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

JSONParseError: Unexpected token is not valid JSON when Authorizing an Org #3146

Closed
kkorynta opened this issue Dec 11, 2024 · 3 comments
Closed

Comments

@kkorynta
Copy link

Summary

Unable to authorize an org and unable to commit project changes to the org as a result.

Expected result

In VS Code, use CTRL+SHIFT+P > SFDX: Authorize an Org > Sandbox > orgName > (in browser) complete OAuth > authorization > VS Code linked to org

Actual result

The authorization process is not completing the callback to VS code.
2024-12-10_16-34-35

The output in VS code displays:
10:28:29.43 sf org:login:web --alias wizard --instance-url https://test.salesforce.com --set-default (node:12604) [DEP0040] DeprecationWarning: The punycodemodule is deprecated. Please use a userland alternative instead. (Usenode --trace-deprecation ... to show where the warning was created) Error (1): Unexpected token '

Additional information

The punycode deprecation warning is also new.

I tried uninstalling node & sfdx CLI. I deleted any node/npm folders from %appdata%\local. Uninstalled & reinstalled the salesforce extension pack (expanded). Note - the Agentforce extension is also producing an unknown error.

I resolved a peer dependency with eslint by updating the project's package.json file for '@salesforce/sfdx-lwc-jest(v5.1.0) andeslint` (8.57.1) then running npm install.

System Information

CLI:
@salesforce/cli/2.68.6 win32-x64 node-v22.11.0

Plugin Version:
@oclif/plugin-autocomplete 3.2.10 (core)
@oclif/plugin-commands 4.1.10 (core)
@oclif/plugin-help 6.2.18 (core)
@oclif/plugin-not-found 3.2.28 (core)
@oclif/plugin-plugins 5.4.17 (core)
@oclif/plugin-search 1.2.16 (core)
@oclif/plugin-update 4.6.13 (core)
@oclif/plugin-version 2.2.16 (core)
@oclif/plugin-warn-if-update-available 3.1.23 (core)
@oclif/plugin-which 3.2.19 (core)
@salesforce/cli 2.68.6 (core)
apex 3.6.3 (core)
api 1.3.2 (core)
auth 3.6.75 (core)
data 3.11.4 (core)
deploy-retrieve 3.15.13 (core)
info 3.4.21 (core)
limits 3.3.40 (core)
marketplace 1.3.6 (core)
org 5.2.4 (core)
packaging 2.9.3 (core)
schema 3.3.42 (core)
settings 2.4.6 (core)
sobject 1.4.46 (core)
telemetry 3.6.23 (core)
templates 56.3.30 (core)
trust 3.7.43 (core)
user 3.6.3 (core)
SF ENV. VARS.
SF_AUTOUPDATE_DISABLE,true
SF_BINPATH,C:\Users\Kelly Shoemake\AppData\Local\sf\client\bin\sf
SF_DISABLE_AUTOUPDATE,true
SF_UPDATE_INSTRUCTIONS,Use "npm update --global @salesforce/cli" to update npm-based installations.
Windows: true
Shell: powershell
Channel: stable

Diagnostics

✅ pass - salesforcedx plugin isn’t installed
✅ pass - you don't have any linked plugins
✅ pass - [@salesforce/plugin-trust] can ping: https://registry.npmjs.org
✅ pass - [@salesforce/plugin-trust] can ping: https://registry.yarnpkg.com
✅ pass - [@salesforce/plugin-trust] can ping: https://registry.npmjs.org/
✅ pass - using latest or latest-rc CLI version
✅ pass - [@salesforce/plugin-deploy-retrieve] sourceApiVersion matches apiVersion
✅ pass - can access: https://test.salesforce.com
✅ pass - can access: https://appexchange.salesforce.com/services/data
✅ pass - can access: https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-win32-x64-buildmanifest
✅ pass - [@salesforce/plugin-auth] CLI supports v2 crypto
✅ pass - [@salesforce/plugin-auth] CLI using stable v1 crypto

@iowillhoit
Copy link
Contributor

Hey @kkorynta, could you please try a few things for me?

  • Update to the latest version of the CLI (currently 2.69.14). We just fixed that punycode warning (release notes)
  • What happens when you run this exact same login command on the command line? I am trying to determine if it is a VSCode issue or a CLI issue.
  • If this is still happening on just the command line, can you run that same login command with the --dev-debug flag and provide the output?

Thanks!

@kkorynta
Copy link
Author

Hi @iowillhoit,

I'm on a tight deadline to get a few projects hammered out, so I managed to fix this last week, the day after I logged this (12/12). I did try a few of those steps above:

What happens when you run this exact same login command on the command line? I am trying to determine if it is a VSCode issue or a CLI issue. I got the same error if it was a direct command or through the command palette. I did not capture a debug, but if I see another issue again in the future I'll grab that.

As far as what I did to fix it

  1. Uninstall node
  2. Uninstall sf cli
  3. Remove all residual folders for node in %appdata%\local\npm-cache (I used this as a reference)
  4. Remove all residual folders for sf cli in %appdata%\local\sf, c:\users\myuser\.sf, c:\users\myuser\.sfdx, c:\program files\sf
  5. Removed all environment variable references for node and sf cli
  6. Reinstall node
  7. Reinstall sf cli
  8. Review/reconfigure environment variables (ie confirm npm & sf were valid commands)
  9. Create a new sf project - I then got a prompt that said there were things that had changed on my disk and asked if I wanted to update to use those new values. I chose yes assuming these were updates to the project.json.
  10. I updated sf cli: @salesforce/cli/2.69.14 win32-x64 node-v22.11.0

I should note, I had tried most of this before I logged the ticket, but I missed the residual folders for sf cli. I also did not mess with my environment variables and I did not create a fresh project from scratch. The first pass also did not resolve punycode, but I believe punycode was mostly a warning. If I had to guess, the removal of the sf residual folders with a cli uninstall was the fix.

@iowillhoit
Copy link
Contributor

Hey @kkorynta, I really appreciate that you took the time to respond! Hopefully it will help someone else in the future 🏆

Based on what you shared, I would guess your assumption is correct. Removing the sf-related directories probably cleaned up some corrupt auth config. For future reference, we have all of the sf config (and auth) directories listed here

If you come across this again, feel free to open a new issue. Thanks again

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

No branches or pull requests

2 participants