Skip to content

Package version commands query an invalid field below api version 61.0 #3481

@kyle-blair

Description

@kyle-blair

Summary

At least some package version commands fail because they query fields that don't exist in lower api versions.

Steps To Reproduce

  1. Authenticate to any devhub org.
  2. Run sf package version report --package 04tKe0000011N4KIAU --json --verbose --api-version 60.0. Any valid 04t id will recreate the issue; this one is from nebula logger.
  3. Run the same command with api version 61.0 or higher and the error goes away. sf package version report --package 04tKe0000011N4KIAU --json --verbose --api-version 61.0.

Expected result

The internal code complies with api version 60.0 and lower when querying package version (Package2Version) fields.

Actual result

The command fails because the field EndToEndBuildDurationInSeconds, which was apparently introduced in api version 61.0, is included in queries even when the api version is less than 61.0.

{
  "name": "ErrorInvalidIdNoMatchingVersionIdError",
  "message": "The Subscriber Package Version Id 04tKe0000011N4KIAU is invalid, as a corresponding Package Version Id was not found",
  "exitCode": 1,
  "context": "PackageVersionReportCommand",
  "stack": "ErrorInvalidIdNoMatchingVersionIdError: The Subscriber Package Version Id 04tKe0000011N4KIAU is invalid, as a corresponding Package Version Id was not found\n    at SfCommandError.from (file:///Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/node_modules/@salesforce/sf-plugins-core/lib/SfCommandError.js:48:16)\n    at PackageVersionReportCommand.catch (file:///Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/node_modules/@salesforce/sf-plugins-core/lib/sfCommand.js:332:47)\n    at PackageVersionReportCommand._run (/Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/command.js:186:29)\n    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)\n    at async Config.runCommand (/Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:456:25)\n    at async run (/Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/main.js:97:16)\n    at async file:///Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/bin/run.js:15:1",
  "cause": "INVALID_FIELD: \nBuildDurationInSeconds,HasMetadataRemoved,EndToEndBuildDurationInSeconds FROM\n                                          ^\nERROR at Row:1:Column:439\nNo such column 'EndToEndBuildDurationInSeconds' on entity 'Package2Version'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.\n    at HttpApi.getError (/Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/node_modules/@jsforce/jsforce-node/lib/http-api.js:310:15)\n    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)\n    at async /Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/node_modules/@jsforce/jsforce-node/lib/http-api.js:127:33\n    at async Query._execute (/Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/node_modules/@jsforce/jsforce-node/lib/query.js:373:22)\n    at async /Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli/node_modules/@jsforce/jsforce-node/lib/query.js:305:17 {\n  data: {\n    message: '\\n' +\n      'BuildDurationInSeconds,HasMetadataRemoved,EndToEndBuildDurationInSeconds FROM\\n' +\n      '                                          ^\\n' +\n      'ERROR at Row:1:Column:439\\n' +\n      \"No such column 'EndToEndBuildDurationInSeconds' on entity 'Package2Version'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.\",\n    errorCode: 'INVALID_FIELD'\n  },\n  errorCode: 'INVALID_FIELD'\n}",
  "warnings": [],
  "code": "ErrorInvalidIdNoMatchingVersionIdError",
  "status": 1,
  "commandName": "PackageVersionReportCommand"
}

Additional information

There are attempts to encapsulate the logic for query generation based on api version, however there are various paths through the code that bypass that logic. On a somewhat related note, it also appears that package versions are--perhaps unintentionally--queried twice. The fix was too involved for me to open a pull request.

Related source code/repo links:
https://github.com/forcedotcom/packaging/blob/c31e6957d4b90c4990e177b63fb5e8d89df5718c/src/interfaces/packagingSObjects.ts#L74
https://github.com/forcedotcom/packaging/pull/606/files#diff-9396d1e854fabd5c1fc4707992df7985cbc356882948a406b5f9680cbbafcbe8

System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.117.7",
  "nodeVersion": "node-v24.11.1",
  "osVersion": "Darwin 24.6.0",
  "rootPath": "/Users/user/.nvm/versions/node/v24.11.1/lib/node_modules/@salesforce/cli",
  "shell": "bash",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.39 (core)",
    "@oclif/plugin-commands 4.1.38 (core)",
    "@oclif/plugin-help 6.2.36 (core)",
    "@oclif/plugin-not-found 3.2.73 (core)",
    "@oclif/plugin-plugins 5.4.54 (core)",
    "@oclif/plugin-search 1.2.36 (core)",
    "@oclif/plugin-update 4.7.16 (core)",
    "@oclif/plugin-version 2.2.36 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.53 (core)",
    "@oclif/plugin-which 3.2.42 (core)",
    "@salesforce/cli 2.117.7 (core)",
    "agent 1.26.0 (core)",
    "apex 3.9.5 (core)",
    "api 1.3.6 (core)",
    "auth 3.9.26 (core)",
    "data 4.0.66 (core)",
    "deploy-retrieve 3.24.5 (core)",
    "info 3.4.100 (core)",
    "limits 3.3.74 (core)",
    "marketplace 1.3.8 (core)",
    "org 5.9.53 (core)",
    "packaging 2.24.2 (core)",
    "schema 3.3.90 (core)",
    "settings 2.4.54 (core)",
    "sobject 1.4.81 (core)",
    "telemetry 3.6.71 (core)",
    "templates 56.4.0 (core)",
    "trust 3.7.113 (core)",
    "user 3.6.44 (core)"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue or pull request that identifies or fixes a bugvalidatedVersion information for this issue has been validated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions