cli icon indicating copy to clipboard operation
cli copied to clipboard

`sfdx force:org:display` fails with `InvalidEncryptedFormatError - The encrypted data is not properly formatted.` for org created with `sf login` command

Open SCWells72 opened this issue 4 years ago • 23 comments

This was reported to me by an IC2 user and I reproduced it locally using just the two CLIs:

$ sf login org --alias org_alias
Successfully authorized <redacted> with ID <redacted>

$ sfdx force:org:display -u org_alias --json
{
  "status": 1,
  "name": "InvalidEncryptedFormatError",
  "message": "The encrypted data is not properly formatted.",
  "exitCode": 1,
  "actions": [
    "If attempting to create a scratch org then re-authorize. Otherwise create a new scratch org."
  ],
  "commandName": "OrgDisplayCommand",
  "stack": "InvalidEncryptedFormatError: The encrypted data is not properly formatted.\n    at AuthInfoCrypto.decrypt (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\node_modules\\@salesforce\\core\\lib\\crypto.js:112:19)\n    at AuthInfoCrypto.crypt (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\node_modules\\@salesforce\\core\\lib\\authInfo.js:134:45)\n    at AuthInfoCrypto.decryptFields (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\node_modules\\@salesforce\\core\\lib\\authInfo.js:123:21)\n    at AuthInfo.getFields (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\node_modules\\@salesforce\\core\\lib\\authInfo.js:463:46)\n    at OrgDisplayCommand.run (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\node_modules\\@salesforce\\plugin-org\\lib\\commands\\force\\org\\display.js:32:33)\n    at async OrgDisplayCommand._run (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\node_modules\\@salesforce\\command\\lib\\sfdxCommand.js:81:40)\n    at async Config.runCommand (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\node_modules\\@oclif\\config\\lib\\config.js:173:24)\n    at async SfdxMain.run (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\node_modules\\@oclif\\command\\lib\\main.js:27:9)\n    at async SfdxMain._run (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\node_modules\\@oclif\\command\\lib\\command.js:43:20)\n    at async Object.run (C:\\Users\\Scott\\AppData\\Local\\sfdx\\client\\7.129.0-c662c12\\dist\\cli.js:162:47)",
  "warnings": []
}

SCWells72 avatar Dec 07 '21 19:12 SCWells72

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.

github-actions[bot] avatar Dec 07 '21 19:12 github-actions[bot]

@SCWells72 any update you made on this error.

vikash123accenture avatar Apr 26 '22 08:04 vikash123accenture

@vikash123accenture no, nothing new to report. Sorry...

SCWells72 avatar Apr 26 '22 13:04 SCWells72

@SCWells72 what could be the root cause for this error, i am getting during deployment.

vikash123accenture avatar Apr 26 '22 13:04 vikash123accenture

Unfortunately I'm just the reporter of this issue and not really sure what's causing it, but assuming you're seeing the same issue that I reported, the workaround is to authorize the org using sfdx instead of sf.

SCWells72 avatar Apr 26 '22 13:04 SCWells72

Hi There,

I got this error while trying to run any sfdx force:source commands against a sandbox.

I re-authorized the sandbox and the errors went away.

Not sure if this will help you, but thought it was worth sharing.

sirideva avatar Apr 27 '22 15:04 sirideva

I also encountered this error while running the metadata deployment against scratch org with both sfdx and cci

"commandName": "OrgDisplayCommand",
"stack": "InvalidEncryptedFormatError: The encrypted data is not properly formatted.\n   
at AuthInfoCrypto.decrypt 

mjh-jhm avatar May 14 '22 15:05 mjh-jhm

I am encountering this error trying to create a scratch org. I am authorized against a dev hub.

seanbrown91 avatar May 19 '22 17:05 seanbrown91

I am also encountering the same issue, detailed log attached, --dev-debug "commandName": "OrgCreateCommand", "stack": "InvalidEncryptedFormatError: The encrypted data is not properly formatted.\n at AuthInfoCrypto.decrypt sfdx-error.pdf

arupsarkar-sfdc avatar May 20 '22 13:05 arupsarkar-sfdc

Hey folks 👋🏼

I'm not able to reproduce this on macOS with both CLIs latest-rc, does anyone have a consistent way to repro this?

Screen Shot 2022-05-20 at 11 31 33

@arupsarkar-sfdc after you re-auth, are you able to run force:org:display -u <username> successfully? Do you notice this error start happening after a specific command is executed?

cristiand391 avatar May 20 '22 14:05 cristiand391

Screen Shot 2022-05-20 at 11 48 24 AM I am thinking of deleting [email protected] in .sfdx folder and reauthorize to see if the error is gone.

arupsarkar-sfdc avatar May 20 '22 15:05 arupsarkar-sfdc

SUCCESS:

NOTE: You might see many .json files please be careful of which one you are deleting, it should correspond to a particular devhub which is causing the error

  1. cd ~/.sfdx
  2. delete the .json file referencing your DevHub in my case for example it is [email protected].
  3. re auth your DevHub, verify the above json file got created.
  4. create scratch orgs

arupsarkar-sfdc avatar May 20 '22 15:05 arupsarkar-sfdc

👋🏼 just chiming in that I can't reproduce this on Windows either

image

RodEsp avatar May 20 '22 16:05 RodEsp

SUCCESS:

NOTE: You might see many .json files please be careful of which one you are deleting, it should correspond to a particular devhub which is causing the error

  1. cd ~/.sfdx
  2. delete the .json file referencing your DevHub in my case for example it is [email protected].
  3. re auth your DevHub, verify the above json file got created.
  4. create scratch orgs

This worked for me!

seanbrown91 avatar May 20 '22 18:05 seanbrown91

you need log out of alll your orgs with command: sfdx auth:logout --all , after that autorize an org again.

1

unnamed

2 unnamed (1)

Regards.

Angeldpg1010 avatar May 24 '22 15:05 Angeldpg1010

you need log out of alll your orgs with command: sfdx auth:logout --all , after that autorize an org again.

1

unnamed

2 unnamed (1)

Regards.

This worked for me. I had the same issue after refreshing sandboxes, but this did the trick.

samhowle avatar Jun 07 '22 00:06 samhowle

I am seeing this issue as well. @cristiand391 I can't reliably reproduce this. It also seems to be org specific. It could be that my local project was created too long ago and something is stale. I don't know.

I can temporarily fix this by re-authorizing my org, but it starts failing again after a day or so. VS Code needs to be closed and re-opened to pick-up the re-authorize.

rmccu avatar Jun 24 '22 17:06 rmccu

I was just trying to create a simple project for an LWC course using my trailhead account when I ran into this problem. No way am I logging out of ~15 accounts. I ended up changing the password on my trailhead account and re-authorized and it fixed the problem.

steveoriver avatar Jun 24 '22 18:06 steveoriver

Encountered this myself - deleting the username json in ~.sfdx and re-authorising solved it.

The Refresh token was not being encrypted!

thiakil avatar Jun 27 '22 05:06 thiakil

We have a fix for this in the works and should be included in the next CLI release candidate.

shetzel avatar Jun 28 '22 16:06 shetzel

I am receiving the following error on the latest version of CLI. Is this the same problem or a different one?

sfdx force:package:list -v DH ERROR running force:package:version:list: 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.

sfdx force:package:version:list -v DH ERROR running force:package:version:list: 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.

bdovh avatar Jul 13 '22 13:07 bdovh

I am getting this issue on latest version, my scratch org seems to report fine but the version create always get the below error:

ERROR running force:package:version:create: 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.

lodossDev avatar Jul 15 '22 21:07 lodossDev

This was fixed in in sfdx v 7.158.1, see release notes: https://github.com/forcedotcom/cli/tree/main/releasenotes/sfdx#71581-july-7-2022

cristiand391 avatar Aug 01 '22 12:08 cristiand391

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

github-actions[bot] avatar Sep 30 '22 02:09 github-actions[bot]

still getting an error while executing force:package:version:create command even though I have upgraded the CLI to the latest version. Error: The encrypted data is not properly formatted. If attempting to create a scratch org then re-authorize. Otherwise create a new scratch org. Any workaround for this?

sharique8 avatar Oct 04 '22 11:10 sharique8

I am getting this issue on latest version, my scratch org seems to report fine but the version create always get the below error:

ERROR running force📦version:create: 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 am getting this issue on latest version, my scratch org seems to report fine but the version create always get the below error:

ERROR running force📦version:create: 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.

@lodossDev Did you get any resolution/workaround for this

sharique8 avatar Oct 04 '22 11:10 sharique8

@sharique8 - This issue has been fixed. However, if your auth file is not properly encrypted you must re-authorize first as a one-time step. I would first verify that you are on the most recent CLI version including all core plugins. Then I would re-auth to your devhub org. Then run your command. I would also use the force:package:beta:version:create command to ensure that works for you. If you still have a problem, run this command: sfdx doctor --command "force:package:beta:version:create" where the command string contains all the command parameters and values you would use. That will generate a few files including a debug log that you can grep for errors.

shetzel avatar Oct 04 '22 16:10 shetzel

@sharique8 - This issue has been fixed. However, if your auth file is not properly encrypted you must re-authorize first as a one-time step. I would first verify that you are on the most recent CLI version including all core plugins. Then I would re-auth to your devhub org. Then run your command. I would also use the force:package:beta:version:create command to ensure that works for you. If you still have a problem, run this command: sfdx doctor --command "force:package:beta:version:create" where the command string contains all the command parameters and values you would use. That will generate a few files including a debug log that you can grep for errors.

@shetzel re-authorizing worked. Thank you for quick response.

sharique8 avatar Oct 04 '22 16:10 sharique8