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

sfdx force:org:create fails on converting circular structure to JSON #1928

Closed
pawel-id opened this issue Feb 11, 2023 · 23 comments
Closed

sfdx force:org:create fails on converting circular structure to JSON #1928

pawel-id opened this issue Feb 11, 2023 · 23 comments
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue logger-replacement

Comments

@pawel-id
Copy link

Summary

sfdx force:org:create fails on converting circular structure to JSON. This fails when default Devhub username is set and SFDX_LOG_LEVEL variable is provided. It crashes even without any parameters to sfdx force:org:create.

Steps To Reproduce:

  1. setup default Devhub username with any command e.g.: sfdx auth sfdxurl store -f auth.txt -a prod -d (note option -d)
  2. issue the command SFDX_LOG_LEVEL=debug sfdx force:org:create

Expected result

Regular message about lacking params of force:org:create command.

Actual result

an error:

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Timeout'
    |     property '_idlePrev' -> object with constructor 'TimersList'
    --- property '_idleNext' closes the circle
    at JSON.stringify (<anonymous>)
    at /Users/pawel/.nvm/versions/node/v18.14.0/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/logger.js:702:31
    at Array.map (<anonymous>)
    at filterSecrets (/Users/pawel/.nvm/versions/node/v18.14.0/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/logger.js:691:41)
    at /Users/pawel/.nvm/versions/node/v18.14.0/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/logger.js:142:37
    at /Users/pawel/.nvm/versions/node/v18.14.0/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/logger.js:617:61
    at Array.forEach (<anonymous>)
    at Logger.applyFilters (/Users/pawel/.nvm/versions/node/v18.14.0/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/logger.js:617:33)
    at Logger.debug (/Users/pawel/.nvm/versions/node/v18.14.0/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/logger.js:514:32)
    at Create.run (/Users/pawel/.nvm/versions/node/v18.14.0/lib/node_modules/sfdx-cli/node_modules/@salesforce/plugin-org/lib/commands/force/org/create.js:26:21)

System Information

{
  "cliVersion": "sfdx-cli/7.187.1",
  "architecture": "linux-arm64",
  "nodeVersion": "node-v18.14.0",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 1.4.4 (core)",
    "@oclif/plugin-commands 2.2.5 (core)",
    "@oclif/plugin-help 5.2.2 (core)",
    "@oclif/plugin-not-found 2.3.17 (core)",
    "@oclif/plugin-plugins 2.3.0 (core)",
    "@oclif/plugin-search 0.0.11 (core)",
    "@oclif/plugin-update 3.1.1 (core)",
    "@oclif/plugin-version 1.2.1 (core)",
    "@oclif/plugin-warn-if-update-available 2.0.24 (core)",
    "@oclif/plugin-which 2.2.12 (core)",
    "alias 2.2.0 (core)",
    "apex 1.5.0 (core)",
    "auth 2.4.0 (core)",
    "community 2.2.0 (core)",
    "config 1.5.0 (core)",
    "custom-metadata 2.1.0 (core)",
    "data 2.2.0 (core)",
    "generator 2.0.17 (core)",
    "info 2.4.0 (core)",
    "limits 2.3.0 (core)",
    "org 2.3.0 (core)",
    "packaging 1.14.1 (core)",
    "schema 2.3.0 (core)",
    "signups 1.4.0 (core)",
    "source 2.4.1 (core)",
    "telemetry 2.1.0 (core)",
    "templates 55.3.0 (core)",
    "trust 2.4.0 (core)",
    "user 2.3.0 (core)",
    "@salesforce/sfdx-plugin-lwc-test 1.0.1 (core)",
    "salesforce-alm 54.8.5 (core)"
  ],
  "osVersion": "Linux 5.15.49-linuxkit",
  "shell": "unknown",
  "rootPath": "/usr/local/lib/node_modules/sfdx-cli"
}

Additional information

it fails same way on latest-rc 7.188.1

might be related to:

@pawel-id pawel-id added the investigating We're actively investigating this issue label Feb 11, 2023
@github-actions
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@jeromegv
Copy link

Confirming I have the same issue on a Bitbucket pipeline

@MathieuCaveSF
Copy link

Me too on bitbucket pipeline

@Amoliere
Copy link

Same issue on my Side on Bitbucet also, I changed the image from my pipeline
"image: salesforce/salesforcedx:7.186.0-slim"
instead of
"image: salesforce/salesforcedx:latest-slim"
and it worked again for me.

But it's not an explanation on the root cause we faced at the beginning.

@mshanemc mshanemc added the bug Issue or pull request that identifies or fixes a bug label Feb 13, 2023
@git2gus
Copy link

git2gus bot commented Feb 13, 2023

This issue has been linked to a new work item: W-12535806

@mshanemc
Copy link
Contributor

I can reproduce this locally, no CI involved. I see the bug happen down in the logging framework, trying to figure out why and how to prevent it.

@dalden1981
Copy link

dalden1981 commented Feb 13, 2023

Same error on sfdx force:package:version:create
Fixed by reading #1907

@tehnrd
Copy link

tehnrd commented Feb 14, 2023

Confirming this is occurring in Github Actions as well, but glad @mshanemc was able to reproduce locally.

A bit of a blocking issue, so hopefully, this gets a priority fix.

Rolling back to 7.186.2 fixed it for me. I've started to call out a specific version in my CI/CD scripts for stability.

npm install [email protected] --global

@mshanemc
Copy link
Contributor

mshanemc commented Feb 14, 2023

best workaround so far: SFDX_LOG_LEVEL=info instead of debug.

another: SF_DISABLE_LOG_FILE=true to ensure you log nothing.

@jdatskuid
Copy link

Just to confirm that I am also seeing this error in our CI builds:

sfdx-cli/7.194.1 linux-x64 node-v18.13.0
Successfully authorized ******** with org ID 00D40000000Mw0SEAS
jwt grant succeeded to hub org

> create-scratch-org
> sfdx force:org:create -v HubOrg -s -f config/project-scratch-def.json -a ciorg -d 1 --wait 60

Error (1): Converting circular structure to JSON
    --> starting at object with constructor 'Timeout'
    |     property '_idlePrev' -> object with constructor 'TimersList'
    --- property '_idleNext' closes the circle

When I set SFDX_LOG_LEVEL=info (as in SFDX_LOG_LEVEL=info sfdx force:org:create ...) the deployment succeeds.

@Kevmo92
Copy link

Kevmo92 commented Apr 3, 2023

best workaround so far: SFDX_LOG_LEVEL=info instead of debug.

Why is debug is the default?

@cristiand391
Copy link
Member

@Kevmo92 there's no default log level, this only happens if you set SFDX_LOG_LEVEL=debug

@Kevmo92
Copy link

Kevmo92 commented Apr 4, 2023

@cristiand391 Why isn't there a default log level set 🤔

@Kevmo92
Copy link

Kevmo92 commented Apr 5, 2023

@mshanemc Instead of consumers implementing a workaround would it make more sense for a default log level to be set in the cli that's attempting to log?

@mshanemc
Copy link
Contributor

mshanemc commented Apr 5, 2023

@Kevmo92 do you get the error without setting SFDX_LOG_LEVEL ?

@jdatskuid
Copy link

For our CI builds, we want as much info as reasonable in the logs so that, when a build breaks, it's easier to diagnose the issue. We set a global ENV SFDX_LOG_LEVEL DEBUG for all of our sfdx commands right in the Dockerfile, but I am now overriding that with SFDX_LOG_LEVEL=info for the buggy commands (sfdx org:create:scratch).

It's unfortunate as I would prefer to have that extra level of log information (I assume that's what "debug" is for... debugging), but stepping down to info allowed our CI environment to finish a build without errors.

@jdatskuid
Copy link

@cristiand391 @Kevmo92 According to Salesforce CLI Configuration and Tips / Log Messages and Log Levels:

The default level of log messages is warn.

@cristiand391
Copy link
Member

@jdatskuid I think that was being set here:
https://github.com/salesforcecli/command/blob/main/src/sfdxFlags.ts#L528

So, commands supporting--log-level would have log level set to warn even if they didn't specify --loglevel warn when running a command because the flag had a default value.

That code was deprecated and removed for almost all commands now, and using that flag just prints a msg showing how to set the log level using the env var:
https://github.com/salesforcecli/sf-plugins-core/blob/de7f99d9c53410cfe6a514a00e45202aafcd35a0/src/compatibility.ts#L37-L49

I'll double-check with my team, otherwise we'll update the docs.

@cristiand391
Copy link
Member

@jdatskuid A teammate mentioned the default log level set is still set to warn in the logger class:
https://github.com/forcedotcom/sfdx-core/blob/main/src/logger.ts#L208

While it's not exactly set as a global in sfdx like with the --loglevel flag, the default still applies unless a plugin/lib sets a different level.

To sum up:

  1. default log level warn is set in the logger utility used by plugins/libraries.
  2. --loglevel is deprecated and no longer sets log level, you should always set it via the SFDX_LOG_LEVEL env var.

@Kevmo92
Copy link

Kevmo92 commented May 1, 2023

@Kevmo92 do you get the error without setting SFDX_LOG_LEVEL ?

yes

@Kevmo92
Copy link

Kevmo92 commented May 1, 2023

Are there any plans to work on a fix that doesn't require an environment variable to be set? Could sfdx cli set the "necessary" env variable in the users session if it's not set? Or is the plan to just replace the logger system and let this issue linger in the meantime?

@shetzel
Copy link
Contributor

shetzel commented May 1, 2023

@Kevmo92 - Yes there are plans to fix the log level bug. However, there are 2 workarounds to this issue:

  1. unset SFDX_LOG_LEVEL
  2. Use the newer command for creating orgs: org create scratch

@cristiand391
Copy link
Member

fixed here: salesforcecli/plugin-org#708

and already available on latest CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue logger-replacement
Projects
None yet
Development

No branches or pull requests