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

Displaying the navigation URL outputs a superfluous error #2208

Closed
ncinolando opened this issue Jul 12, 2019 · 5 comments
Closed

Displaying the navigation URL outputs a superfluous error #2208

ncinolando opened this issue Jul 12, 2019 · 5 comments

Comments

@ncinolando
Copy link

ncinolando commented Jul 12, 2019

Summary

Using the URL Only and JSON output options for the force:org:open command appends an additional error with no explanation.

Steps To Reproduce:

This error did not show up until I upgraded my Node.js version and installed sfdx-cli via npm for that version.

  1. Install a fresh version of Node.js (either through nvm or uninstalling and reinstalling).
  2. Install the sfdx-cli tool via npm for the newly installed Node.js version.
  3. Ensure the SFDX_LOG_LEVEL environment variable is set to debug.
  4. Identify an existing scratch org or create a new scratch org.
  5. Execute sfdx force:org:open --urlonly --json -u <IDENTIFIED_ORG_USERNAME>

Expected result

The command should display a JSON only output that can easily be consumed by JSON accepting scripts.

{
  "status": 0,
  "result": {
    "orgId": "<ORG_ID>",
    "url": "https://<SALESFORCE_INSTANCE_URL>/secur/frontdoor.jsp?sid=<ORG_ID>!<TOKEN>",
    "username": "<USERNAME>"
  }
}

Actual result

The JSON output does display, but a random error is printed underneath which seems unrelated.

{
  "status": 0,
  "result": {
    "orgId": "<ORG_ID>",
    "url": "https://<SALESFORCE_INSTANCE_URL>/secur/frontdoor.jsp?sid=<ORG_ID>!<TOKEN>",
    "username": "<USERNAME>"
  }
}
JsonParseError: Unexpected end of JSON input
    at Function.create (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/@salesforce/kit/lib/errors.js:49:20)
    at Object.parseJson (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/@salesforce/kit/lib/json.js:27:39)
    at args.map.arg (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/node_modules/@salesforce/core/lib/logger.js:548:53)
    at Array.map (<anonymous>)
    at _filter (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/node_modules/@salesforce/core/lib/logger.js:500:17)
    at Logger.addFilter.args (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/node_modules/@salesforce/core/lib/logger.js:96:37)
    at bunyan.filters.forEach (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/node_modules/@salesforce/core/lib/logger.js:456:61)
    at Array.forEach (<anonymous>)
    at Logger.applyFilters (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/node_modules/@salesforce/core/lib/logger.js:456:33)
    at Logger.info (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/node_modules/@salesforce/core/lib/logger.js:421:31)
    at UX.logJson (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/ux.js:103:21)
    at OrgOpenCommand.finally (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:305:25)
    at OrgOpenCommand._run (~/.nvm/versions/node/v10.16.0/lib/node_modules/sfdx-cli/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:98:31)

Additional information

This issue currently causes automated scripts to fail that assume only JSON will be output from this command.

image

The issue seems be due to logger.ts. The Regex pattern sid=(.*) seems to be replacing the rest of the JSON string with a <HIDDEN> string for the log. When the logger tries to parse the JSON, the JSON string is invalid.

While the JSON logged should look like this:

{"status":0,"result":{"orgId":"??????????????????","url":"https://some-words-####-dev-ed.cs##.my.salesforce.com/secur/frontdoor.jsp?sid=<HIDDEN>","username":"[email protected]"}}

it actually ends up being this:

{"status":0,"result":{"orgId":"??????????????????","url":"https://some-words-####-dev-ed.cs##.my.salesforce.com/secur/frontdoor.jsp?sid=<HIDDEN>"

My current workaround is to overwrite the local file logger.js in the @salesforce/core/lib directory to use a different regex pattern that does not match to the end of the string:

_arg = _arg.replace(/sid=([A-Za-z0-9._!]+)/, `sid=<${HIDDEN}>`);

SFDX CLI Version: sfdx-cli/7.14.0 darwin-x64 node-v10.16.0

SFDX plugin Version: salesforcedx 46.4.0 (core)

OS and version: macOS Mojave (10.14.5)

@clairebianchi
Copy link
Contributor

@callietoothman we are unable to reproduce in the current CLI, can you update your CLI and try again

@ncinolando
Copy link
Author

@clairebianchi Updated sfdx, same issue:

SFDX CLI Version: sfdx-cli/7.33.2 darwin-x64 node-v10.16.0

SFDX plugin Version: salesforcedx 47.6.2 (core)

OS and version: macOS Mojave (10.14.6)

image

@paferpo
Copy link

paferpo commented May 27, 2020

FYI: I experienced the same issue after setting the environment variable for nodejs DEBUG=app

@ncinolando
Copy link
Author

Ahhh! Thanks! I didn't have DEBUG=app, but I did have SFDX_LOG_LEVEL=debug. When I unset it, the error disappeared.

@ncinolando
Copy link
Author

@clairebianchi You should be able to run the following to reproduce the error:

SFDX_LOG_LEVEL=debug sfdx force:org:open --urlonly --json

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

4 participants