InvalidEncryptedFormatError when trying to use a connection which was created using sf org login

Issue #2021 resolved
Maddy Singh created an issue

Not sure if the connections are interchangeable. But if I use sf commands to authorize an org, it does get listed in, but I receive this error when trying to do any operation like running anonymous Apex.

SFDX Version

sfdx-cli/7.126.0 win32-x64 node-v16.13.0

Comments (5)

  1. Scott Wells repo owner

    IC2 will include any (active) connection from the CLI. That status is coming directly from the CLI. You should see it in the CLI directly if you run:

    sfdx force:org:list --skipconnectionstatus --json
    

    For that connection, you should see InvalidEncryptedFormatError as the value for connectedStatus. Whenever the CLI includes a value for connectedStatus other than Connected, it will display it beside the associated connection.

  2. Scott Wells repo owner

    If you do find that authorizations created using the sf CLI are not usable by IC2, we should report that to the CLI team directly as those commands are supposed to yield compatible results. In the case of anonymous Apex execution, IC2 uses the access token for the connection reported by sfdx force:org:list as its authorization header when making the API call. If the access token from an sf-auth'ed connection isn't valid as an API authorization header, that would be a bug in the sf auth command.

  3. Scott Wells repo owner

    I was able to reproduce this behavior by authorizing a connection using sf and trying to use sfdx force:org:display to get details for that connection:

    $ sf login org --alias field_history_sf
    Successfully authorized scottwells@fieldhistory.illuminatedcloud.com with ID 00D4x0000030fahEAA
    
    $ sfdx force:org:display -u field_history_sf
    ERROR running force:org:display:  The encrypted data is not properly formatted.
    
    Try this:
    If attempting to create a scratch org then re-authorize. Otherwise create a new scratch org.
    

    I'll log a support case with the CLI team.

  4. Log in to comment