Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with API Version 62.0 in sf-cli causing INVALID_CROSS_REFERENCE_KEY error #3093

Closed
Alfystar opened this issue Nov 4, 2024 · 3 comments
Labels
investigating We're actively investigating this issue validated Version information for this issue has been validated

Comments

@Alfystar
Copy link

Alfystar commented Nov 4, 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' --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)"
  ]
}
@Alfystar Alfystar added the investigating We're actively investigating this issue label Nov 4, 2024
@github-actions github-actions bot added the validated Version information for this issue has been validated label Nov 4, 2024
Copy link

github-actions bot commented Nov 4, 2024

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.

@cristiand391
Copy link
Member

I found a customer investigation that reported the same issue ~2 weeks ago:

The customer is facing an issue with listing CustomObjectTranslation items through the metadata API using the listMetadata SOAP Call from Postman Salesforce Platform API standard collection after Winter 25 release in the production and sandbox orgs.
If we include the CustomObjectTranslation type in the SOAP query, we get the following error back:
INVALID_CROSS_REFERENCE_KEY: invalid cross reference id.
...
However, when the API version 61.0 was set in the SOAP envelope tag 61.0, the issue didn’t happen.

The closing summary mentioned that support had to do some clean up in the org to fix the issue so you'll need to open a support case to investigate further in your specific org. (W-17068814 is ID of the inv mentioned above, you can share it with support to speed up the investigation process).

Make the type of error more obvious, the solution was found by random attempts (desperation)

There's not much we can add to help debug these failures, we call listMetadata here:
https://github.com/salesforcecli/plugin-org/blob/3fc3058954b8f8115701e2b03048782e3155b675/src/commands/org/list/metadata.ts#L59

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_listmetadata.htm

maybe something like listMetadata(<mdtype>) failed due to: <error> to improve the final error.

Consider officially adding support for the apiVersion parameter in the sfdx-project.json file to allow for easier configuration.

I can't remember if there was an argument against this, would you mind opening a feature request here?
https://github.com/forcedotcom/cli/discussions

people can vote/discuss design before we pick up new work.

for reference, current supported options for setting API version:
https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_apiversion.htm

@cristiand391
Copy link
Member

closing this, let us know if you need help to connect support with previous investigations to solve your issue.

For reference, apiVersion in sfdx-project discussion:
#3108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating We're actively investigating this issue validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

2 participants