question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

force:auth:jwt:grant / force:mdapi:deploy failing in 7.88.4 / 51.0.4 - FILE HAS NO CONTENT

See original GitHub issue

Summary

Since 7.88.4 / 51.0.4 running force:mdapi:deploy after force:auth:jwt:grant is failing with the following error message:

Successfully authorized USERNAME with org ID ORGID
ERROR running force:mdapi:deploy:  Parse error in file /root/.sfdx/USERNAME.json on line 1
FILE HAS NO CONTENT

A subsequent deployment using the same alias works so my assumption is that maybe the writing of the auth info to the file hasn’t completed by the time the deploy command runs? These commands are run one after another in our build tools.

I have tests that check our build scripts before publishing a docker container with new SFDX versions - the build scripts haven’t changed, the tests haven’t changed and the tests reliably fail at the same point so something must have changed around the auth commands or deploy commands (the auth commands seem more likely based on the error).

Steps To Reproduce:

Run force:mdapi:deploy immediately after a successful jwt authentication using force:auth:jwt:grant.

Expected result

Deploy command should initiate a deployment.

Actual result

Error, as above.

Additional information

SFDX CLI Version(to find the version of the CLI engine run sfdx --version):

SFDX plugin Version(to find the version of the CLI plugin run sfdx plugins --core)

@oclif/plugin-autocomplete 0.3.0 (core) @oclif/plugin-commands 1.3.0 (core) @oclif/plugin-help 3.2.2 (core) @oclif/plugin-not-found 1.2.4 (core) @oclif/plugin-plugins 1.9.5 (core) @oclif/plugin-update 1.4.0-2 (core) @oclif/plugin-warn-if-update-available 1.7.0 (core) @oclif/plugin-which 1.0.3 (core) @salesforce/sfdx-trust 3.6.0 (core) alias 1.1.5 (core) auth 1.4.8 (core) config 1.2.4 (core) generator 1.1.5 (core) salesforcedx 51.0.4 (core) ├─ limits 1.0.4 (core) ├─ user 1.1.2 (core) ├─ schema 1.0.4 (core) ├─ custom-metadata 1.0.11 (core) ├─ apex 0.1.4 (core) ├─ @salesforce/sfdx-plugin-lwc-test 0.1.7 (core) ├─ templates 51.2.0 (core) └─ salesforce-alm 51.0.2 (core) sfdx-cli 7.88.4 (core) sfdx-destruction 1.0.0-beta.3 telemetry 1.1.1 (core)

OS and version:

Issue found in our docker container - Alpine Linux (see makepositive/sfdx-ant:7.88.4-2.5 for the exact container).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
jayaprakashcommented, Feb 25, 2021

We are encountering the same issue as well since 22-Feb when trying the deploy and query command: sfdx force:mdapi:deploy sfdx force:data:soql:query

Version

Error

  • sfdx force:mdapi:deploy -d dist/deployment-package -u **** -c --json --loglevel debug { “status”: 1, “name”: “Error”, “message”: “Parse error in file /home/jenkins/.sfdx/username.json on line 1\nFILE HAS NO CONTENT\n”, “exitCode”: 1, “commandName”: “MdapiDeployCommand”, “stack”: "Error: Parse error in file /home/jenkins/.sfdx/username.json on line 1\nFILE HAS NO CONTENT\n\n .

We even tried to display the contents of the username.json and it wasn’t empty as indicated by the error: image

I too noticed the issue frequently and randomly on docker container - Alpine Linux. Happening with the upgrade of sfdx-cli to latest, latest-rc or even the downgraded 7.83.0

2reactions
pacafuentescommented, Feb 23, 2021

I ran sfdx force:org:list between sfdx force:auth:jwt:grant and sfdx force:org:create and it worked for me.

Im also running it in my build steps of the CI

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found