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

org resume sandbox fails with The query returned more than 1 record #2238

Closed
mkhokhlov opened this issue Jun 21, 2023 · 10 comments
Closed

org resume sandbox fails with The query returned more than 1 record #2238

mkhokhlov opened this issue Jun 21, 2023 · 10 comments
Labels
bug Issue or pull request that identifies or fixes a bug investigating We're actively investigating this issue validated Version information for this issue has been validated

Comments

@mkhokhlov
Copy link

Summary

The org resume sandbox command fails with The query returned more than 1 record.

Steps To Reproduce

  1. Initiate a sandbox refresh
  2. Run the org resume sandbox command.

Expected result

Returns the status of a sandbox creation, and log in to it if it's ready: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_resume_sandbox_unified

Actual result

{
  "code": 1,
  "context": "ResumeSandbox",
  "commandName": "ResumeSandbox",
  "message": "The query returned more than 1 record",
  "name": "SingleRecordQuery_MultipleRecords",
  "status": 1,
  "stack": "SingleRecordQuery_MultipleRecords: The query returned more than 1 record\n    at Connection.singleRecordQuery (/Users/mkhokhlov/.npm-packages/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/org/connection.js:325:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Org.resumeSandbox (/Users/mkhokhlov/.npm-packages/lib/node_modules/sfdx-cli/node_modules/@salesforce/core/lib/org/org.js:148:39)\n    at async ResumeSandbox.resumeSandbox (/Users/mkhokhlov/.npm-packages/lib/node_modules/sfdx-cli/node_modules/@salesforce/plugin-org/lib/commands/org/resume/sandbox.js:78:20)\n    at async ResumeSandbox._run (/Users/mkhokhlov/.npm-packages/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/command.js:117:22)\n    at async Config.runCommand (/Users/mkhokhlov/.npm-packages/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/config/config.js:329:25)\n    at async run (/Users/mkhokhlov/.npm-packages/lib/node_modules/sfdx-cli/node_modules/@oclif/core/lib/main.js:89:16)",
  "exitCode": 1,
  "warnings": []
}

System Information

{
  "cliVersion": "sfdx-cli/7.205.6",
  "architecture": "darwin-x64",
  "nodeVersion": "node-v18.10.0",
  "osVersion": "Darwin 22.5.0",
  "shell": "bash",
  "rootPath": "/Users/mkhokhlov/.npm-packages/lib/node_modules/sfdx-cli",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 2.3.0 (core)",
    "@oclif/plugin-commands 2.2.15 (core)",
    "@oclif/plugin-help 5.2.9 (core)",
    "@oclif/plugin-not-found 2.3.24 (core)",
    "@oclif/plugin-plugins 3.1.2 (core)",
    "@oclif/plugin-search 0.0.17 (core)",
    "@oclif/plugin-update 3.1.17 (core)",
    "@oclif/plugin-version 1.3.4 (core)",
    "@oclif/plugin-warn-if-update-available 2.0.37 (core)",
    "@oclif/plugin-which 2.2.22 (core)",
    "@salesforce/analytics 1.0.11 (user)",
    "@salesforce/lwc-dev-server 2.11.0 (user)",
    "apex 2.3.3 (core)",
    "auth 2.8.1 (core)",
    "community 2.3.1 (core)",
    "custom-metadata 2.1.25 (core)",
    "data 2.3.22 (core)",
    "deploy-retrieve 1.11.7 (core)",
    "info 2.6.19 (core)",
    "limits 2.3.18 (core)",
    "org 2.9.8 (core)",
    "packaging 1.19.0 (core)",
    "schema 2.3.12 (core)",
    "settings 1.4.11 (core)",
    "signups 1.4.21 (core)",
    "source 2.10.14 (core)",
    "telemetry 2.2.0 (core)",
    "templates 55.4.20 (core)",
    "trust 2.4.20 (core)",
    "user 2.3.17 (core)",
    "sfdmu 4.17.6 (user)",
    "sfdx-cli 7.205.6 (core)"
  ]
}

Additional information

Reproducible in any version.

@mkhokhlov mkhokhlov added the investigating We're actively investigating this issue label Jun 21, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot added the validated Version information for this issue has been validated label Jun 21, 2023
@mshanemc
Copy link
Contributor

mshanemc commented Jun 21, 2023

That command org resume sandbox is for connecting to a sandbox that's been kicked off from org create sandbox so the CLI knows about which sandbox, etc.

The CLI doesn't really support the sandbox refresh process very well--we should probably handle that scenario (have a way to start a refresh from the CLI and then be able to resume that).

I'm going to use this issue as a "fix the error message" and handle the refresh stuff as a separate feature request

@mshanemc mshanemc added the bug Issue or pull request that identifies or fixes a bug label Jun 21, 2023
@git2gus
Copy link

git2gus bot commented Jun 21, 2023

This issue has been linked to a new work item: W-13635704

@mkhokhlov
Copy link
Author

mkhokhlov commented Jun 21, 2023

The predecessor command force:org:status worked just fine for sandbox refreshes up until at least 7.146.1. Not sure which version it was broken in, but 7.162.0 was the one where I faced it first. I aired my frustrations and some findings in #1749 (comment). Someone else posted their research in #1833 (comment).

@ahdong
Copy link

ahdong commented Jul 24, 2023

I'm running into this same issue when running org resume sandbox without refreshing the sandbox. Tried the command with a couple of different sandboxes and getting the same error with each.

@kyle-blair
Copy link

Issue #1833 is identical to this one and was auto-closed against my wishes. Voicing my frustration about that.

@ahdong
Copy link

ahdong commented Oct 3, 2023

I am noticing that the Status of the related SandboxProcess record is stuck in Deleting from the last couple of years. I wonder if it's due to a difference in the query used by force:org:status and sf org resume sandbox. If I had to take a guess the old command filtered for orgs that had a Completed status, while the new command filters by not Deleted status.

@shetzel
Copy link
Contributor

shetzel commented Oct 3, 2023

@ahdong - Yes, there is a difference in the query used by force:org:status versus org resume sandbox. The former has this at the end of the query which makes the difference: ORDER BY CreatedDate DESC LIMIT 1. The latter uses a singleRecordQuery call that throws when finding multiple results in a resumable state (aside: Deleting is not a resumable state so that is another problem with the code).

@kyle-blair - Apologies about the auto-close of 1833. That should never have happened. You did a lot of work to provide detailed, useful information and it looks like our bot had some issues. Thanks for the info you provided!

The good news is that this issue should be fixed with a few PRs that I have in the works. I believe it provides the most flexible solution by restoring the old behavior while providing more information about other SandboxProcesses in a resumable state. I'm hopeful this will go into the next CLI release candidate in a few days.

For details, see:
forcedotcom/sfdx-core#944
salesforcecli/plugin-org#823

@shetzel
Copy link
Contributor

shetzel commented Oct 5, 2023

This issue is fixed in the CLI release candidate just published, v2.12.9. Feel free to install that version, try it out and report back.

@iowillhoit
Copy link
Contributor

Fixed in the latest version of sf 2.12.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug 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

6 participants