1

The GitLab pipeline was running successfully until a few days ago. Nothing has been changed as far as we're aware, but it now fails on the authentication step with

"We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: Error authenticating with JWT config due to: Value is not a JsonMap"

I can't find any other posts mentioning that error.

The command being run is

sfdx force:auth:jwt:grant -u $local_salesforce_username -i $local_client_id -f server.key -r $local_login_url --json | jq 'del(.result.accessToken,.result.clientId)'

If I run that from the command line in VS Code with actual values and the cert file instead of variables, I get a successful authentication.

In case you're not familiar with it, jq is a bash command that can be installed to manipulate json. In this case it is used to remove sensitive values from the log file.

This is the response (with some values anonymised) when run from the command line:

{
  "status": 0,
  "result": {
    "orgId": "00D5t0000008iZZZZZ",
    "loginUrl": "https://blah--build.my.salesforce.com/",
    "privateKey": "C:\\Users\\Mike\\sk.txt",
    "instanceUrl": "https://blah--build.sandbox.my.salesforce.com",
    "isDevHub": false,
    "username": "[email protected]"
  }
}

The result when run in the GitLab pipeline is

{
  "status": 1,
  "name": "JwtGrant",
  "message": "We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: Error authenticating with JWT config due to: Value is not a JsonMap",
  "exitCode": 1,
  "context": "Grant",
  "stack": "JwtGrant: We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: Error authenticating with JWT config due to: Value is not a JsonMap\n    at Messages.createError (/usr/local/lib/nodejs/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/messages.js:446:16)\n    at Grant.run (/usr/local/lib/nodejs/lib/node_modules/sfdx-cli/node_modules/@salesforce/plugin-auth/lib/commands/auth/jwt/grant.js:35:28)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async Grant._run (/usr/local/lib/nodejs/lib/node_modules/sfdx-cli/node_modules/@salesforce/command/lib/sfdxCommand.js:89:40)\n    at async Config.runCommand (/usr/local/lib/nodejs/lib/node_modules/sfdx-cli/node_modules/@oclif/config/lib/config.js:173:24)\n    at async SfdxMain.run (/usr/local/lib/nodejs/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/main.js:27:9)\n    at async SfdxMain._run (/usr/local/lib/nodejs/lib/node_modules/sfdx-cli/node_modules/@oclif/command/lib/command.js:43:20)\n    at async Object.run (/usr/local/lib/nodejs/lib/node_modules/sfdx-cli/dist/cli.js:162:47)",
  "warnings": [],
  "commandName": "Grant"
}

Can anyone suggest why this has started happening when it has been running successfully for a long time?

6
  • 1
    What's your Salesforce CLI version? It would be helpful to know that. Commented Oct 21, 2022 at 16:28
  • 1
    On the local terminal where it runs successfully, $ sfdx --version returns sfdx-cli/7.169.1 win32-x64 node-v16.17.0. Unfortunately, I have not yet found who has access to the location where the pipeline runs so I cannot provide that. I have added --loglevel on the pipeline, so once I have access, I will post the version and anything useful from the log here.
    – MikeA
    Commented Oct 23, 2022 at 22:12
  • 1
    @MohithShrivastava Pipeline CLI version is sfdx-cli/7.150.0 linux-x64 node-v16.13.2
    – MikeA
    Commented Oct 24, 2022 at 17:23
  • Could that because for it? Could you try using the latest version and see if that helps Commented Oct 24, 2022 at 18:14
  • That was it @MohithShrivastava, the pipeline was updated to use the latest, which is 7.173.0, and now it is successful. If you can you put your comment as an answer I will accept it.
    – MikeA
    Commented Oct 27, 2022 at 10:50

1 Answer 1

1

This error is a bug in the previous version of the Salesforce CLI.

Update to the latest version of the Salesforce CLI.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .