Summary
I encountered an issue with the Salesforce CLI (sf-cli) when using API version 62.0.
The command
sf org list metadata --metadata-type CustomObjectTranslation --target-org 'PROD_RM' --json
resulted in the following error: (Note, in DevOrg and UAT same cli command work)
{
"name": "sf:INVALID_CROSS_REFERENCE_KEY",
"message": "INVALID_CROSS_REFERENCE_KEY: invalid cross reference id",
"exitCode": 1,
"context": "ListMetadata",
"data": {
"errorCode": "sf:INVALID_CROSS_REFERENCE_KEY",
"message": "INVALID_CROSS_REFERENCE_KEY: invalid cross reference id"
},
"stack": "sf:INVALID_CROSS_REFERENCE_KEY: INVALID_CROSS_REFERENCE_KEY: invalid cross reference id\n at SfCommandError.from (file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@salesforce/sf-plugins-core/lib/SfCommandError.js:39:16)\n at ListMetadata.catch (file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@salesforce/sf-plugins-core/lib/sfCommand.js:316:47)\n at ListMetadata._run (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/command.js:305:29)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async Config.runCommand (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/config/config.js:424:25)\n at async run (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/main.js:95:16)\n at async file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/bin/run.js:15:1",
"cause": "sf:INVALID_CROSS_REFERENCE_KEY: INVALID_CROSS_REFERENCE_KEY: invalid cross reference id\n at SOAP.getError (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@jsforce/jsforce-node/lib/http-api.js:290:56)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async /Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@jsforce/jsforce-node/lib/http-api.js:127:33\n at async SOAP.invoke (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@jsforce/jsforce-node/lib/soap.js:186:21)\n at async MetadataApi._invoke (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@jsforce/jsforce-node/lib/api/metadata.js:73:21)\n at async ListMetadata.run (file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@salesforce/plugin-org/lib/commands/org/list/metadata.js:50:28)\n at async ListMetadata._run (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/command.js:301:22)\n at async Config.runCommand (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/config/config.js:424:25)\n at async run (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/main.js:95:16)\n at async file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/bin/run.js:15:1 {\n data: {\n errorCode: 'sf:INVALID_CROSS_REFERENCE_KEY',\n message: 'INVALID_CROSS_REFERENCE_KEY: invalid cross reference id'\n },\n errorCode: 'sf:INVALID_CROSS_REFERENCE_KEY'\n}",
"warnings": [],
"code": "1",
"status": 1,
"commandName": "ListMetadata"
}
Resolution
I resolved the issue by downgrading the API version to 61.0. Here are the steps I followed:
- Added the key "apiVersion": "61.0" to
sfdx-project.json.
- Set the API version in my bash script with:
apiVersion=$(jq -r '.apiVersion' sfdx-project.json)
sf config set org-api-version="$apiVersion"
Request
- Please investigate and resolve the issue with API version 62.0.
- Make the type of error more obvious, the solution was found by random attempts (desperation)
- Consider officially adding support for the
apiVersion parameter in the sfdx-project.json file to allow for easier configuration.
System Information
{
"architecture": "darwin-arm64",
"cliVersion": "@salesforce/cli/2.64.8",
"nodeVersion": "node-v20.17.0",
"osVersion": "Darwin 23.6.0",
"rootPath": "/Users/ea_enel/.local/share/sf/client/2.64.8-21fd4e6",
"shell": "zsh",
"pluginVersions": [
"@oclif/plugin-autocomplete 3.2.6 (core)",
"@oclif/plugin-commands 4.1.3 (core)",
"@oclif/plugin-help 6.2.16 (core)",
"@oclif/plugin-not-found 3.2.22 (core)",
"@oclif/plugin-plugins 5.4.15 (core)",
"@oclif/plugin-search 1.2.12 (core)",
"@oclif/plugin-update 4.6.6 (core)",
"@oclif/plugin-version 2.2.15 (core)",
"@oclif/plugin-warn-if-update-available 3.1.20 (core)",
"@oclif/plugin-which 3.2.16 (core)",
"@salesforce/cli 2.64.8 (core)",
"apex 3.5.4 (core)",
"api 1.3.1 (core)",
"auth 3.6.70 (core)",
"data 3.8.1 (core)",
"deploy-retrieve 3.13.1 (core)",
"info 3.4.13 (core)",
"limits 3.3.36 (core)",
"marketplace 1.3.0 (core)",
"org 4.7.2 (core)",
"packaging 2.8.12 (core)",
"schema 3.3.37 (core)",
"settings 2.3.24 (core)",
"sobject 1.4.42 (core)",
"source 3.5.21 (core)",
"telemetry 3.6.17 (core)",
"templates 56.3.24 (core)",
"trust 3.7.35 (core)",
"user 3.5.33 (core)",
"sfdx-plugin-source-read 1.2.2 (user) published 8 days ago (Sat Oct 26 2024)"
]
}
Summary
I encountered an issue with the Salesforce CLI (sf-cli) when using API version 62.0.
The command
sf org list metadata --metadata-type CustomObjectTranslation --target-org 'PROD_RM' --jsonresulted in the following error: (Note, in DevOrg and UAT same cli command work)
{ "name": "sf:INVALID_CROSS_REFERENCE_KEY", "message": "INVALID_CROSS_REFERENCE_KEY: invalid cross reference id", "exitCode": 1, "context": "ListMetadata", "data": { "errorCode": "sf:INVALID_CROSS_REFERENCE_KEY", "message": "INVALID_CROSS_REFERENCE_KEY: invalid cross reference id" }, "stack": "sf:INVALID_CROSS_REFERENCE_KEY: INVALID_CROSS_REFERENCE_KEY: invalid cross reference id\n at SfCommandError.from (file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@salesforce/sf-plugins-core/lib/SfCommandError.js:39:16)\n at ListMetadata.catch (file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@salesforce/sf-plugins-core/lib/sfCommand.js:316:47)\n at ListMetadata._run (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/command.js:305:29)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async Config.runCommand (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/config/config.js:424:25)\n at async run (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/main.js:95:16)\n at async file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/bin/run.js:15:1", "cause": "sf:INVALID_CROSS_REFERENCE_KEY: INVALID_CROSS_REFERENCE_KEY: invalid cross reference id\n at SOAP.getError (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@jsforce/jsforce-node/lib/http-api.js:290:56)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async /Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@jsforce/jsforce-node/lib/http-api.js:127:33\n at async SOAP.invoke (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@jsforce/jsforce-node/lib/soap.js:186:21)\n at async MetadataApi._invoke (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@jsforce/jsforce-node/lib/api/metadata.js:73:21)\n at async ListMetadata.run (file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@salesforce/plugin-org/lib/commands/org/list/metadata.js:50:28)\n at async ListMetadata._run (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/command.js:301:22)\n at async Config.runCommand (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/config/config.js:424:25)\n at async run (/Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/node_modules/@oclif/core/lib/main.js:95:16)\n at async file:///Users/ea_enel/.local/share/sf/client/2.58.7-ed27925/bin/run.js:15:1 {\n data: {\n errorCode: 'sf:INVALID_CROSS_REFERENCE_KEY',\n message: 'INVALID_CROSS_REFERENCE_KEY: invalid cross reference id'\n },\n errorCode: 'sf:INVALID_CROSS_REFERENCE_KEY'\n}", "warnings": [], "code": "1", "status": 1, "commandName": "ListMetadata" }Resolution
I resolved the issue by downgrading the API version to 61.0. Here are the steps I followed:
sfdx-project.json.Request
apiVersionparameter in thesfdx-project.jsonfile to allow for easier configuration.System Information
{ "architecture": "darwin-arm64", "cliVersion": "@salesforce/cli/2.64.8", "nodeVersion": "node-v20.17.0", "osVersion": "Darwin 23.6.0", "rootPath": "/Users/ea_enel/.local/share/sf/client/2.64.8-21fd4e6", "shell": "zsh", "pluginVersions": [ "@oclif/plugin-autocomplete 3.2.6 (core)", "@oclif/plugin-commands 4.1.3 (core)", "@oclif/plugin-help 6.2.16 (core)", "@oclif/plugin-not-found 3.2.22 (core)", "@oclif/plugin-plugins 5.4.15 (core)", "@oclif/plugin-search 1.2.12 (core)", "@oclif/plugin-update 4.6.6 (core)", "@oclif/plugin-version 2.2.15 (core)", "@oclif/plugin-warn-if-update-available 3.1.20 (core)", "@oclif/plugin-which 3.2.16 (core)", "@salesforce/cli 2.64.8 (core)", "apex 3.5.4 (core)", "api 1.3.1 (core)", "auth 3.6.70 (core)", "data 3.8.1 (core)", "deploy-retrieve 3.13.1 (core)", "info 3.4.13 (core)", "limits 3.3.36 (core)", "marketplace 1.3.0 (core)", "org 4.7.2 (core)", "packaging 2.8.12 (core)", "schema 3.3.37 (core)", "settings 2.3.24 (core)", "sobject 1.4.42 (core)", "source 3.5.21 (core)", "telemetry 3.6.17 (core)", "templates 56.3.24 (core)", "trust 3.7.35 (core)", "user 3.5.33 (core)", "sfdx-plugin-source-read 1.2.2 (user) published 8 days ago (Sat Oct 26 2024)" ] }