The requested resource does not exist when run sf data query
Summary
When we use command sf data query --query $theQuery --bulk --target-org $theOrg --wait 5 --json to query data in pipeline (Azure DevOps), we get error like this:
{'code': 1, 'context': 'DataSoqlQueryCommand', 'commandName': 'DataSoqlQueryCommand', 'message': 'The requested resource does not exist', 'name': 'NOT_FOUND', 'status': 1, 'stack': 'NOT_FOUND: The requested resource does not exist\n at SfError.create (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/core/lib/sfError.js:81:23)\n at SfError.wrap (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/core/lib/sfError.js:104:25)\n at DataSoqlQueryCommand.runBulkSoqlQuery (file:///usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-data/lib/commands/data/query.js:143:77)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async DataSoqlQueryCommand.run (file:///usr/local/lib/node_modules/@salesforce/cli/node_modules/@salesforce/plugin-data/lib/commands/data/query.js:97:19)\n at async DataSoqlQueryCommand._run (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/command.js:311:22)\n at async Config.runCommand (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:433:25)\n at async run (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/main.js:92:16)', 'exitCode': 1, 'warnings': []}
But it works correct if run the script in local. Any ideas on this error?
Steps To Reproduce
Run query like above within Python script from pipeline.
Expected result
No error
Actual result
Throw above error
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.
Hello @gtiancai :wave: It looks like you didn't include the full Salesforce CLI version information in your issue.
Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).
A few more things to check:
- Make sure you've provided detailed steps to reproduce your issue.
- A repository that clearly demonstrates the bug is ideal.
- Make sure you've installed the latest version of Salesforce CLI. (docs)
- Better yet, try the
rcornightlyversions. (docs)
- Better yet, try the
- Try running the
doctorcommand to diagnose common issues. - Search GitHub for existing related issues.
Thank you!
Output of doctor command: 2024-05-09T08:53:54.309Z config init hook done 2024-05-09T08:53:54.310Z config runCommand SELECT:Id,:Class__c,:Message__c,:Level__c,:Reference__c,:CreatedDate,:CreatedBy.Name:FROM:MyTable__cc:WHERE:CreatedDate [ '=', 'Yesterday', 'AND', 'Level__c', '=', 'MOBILE ERROR' ] 2024-05-09T08:53:54.310Z config start command_not_found hook 2024-05-09T08:53:54.311Z config:ts-path Skipping typescript path lookup for /usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/plugin-not-found because NODE_ENV is NOT "test" or "development" 2024-05-09T08:53:54.439Z sf:@oclif/plugin-not-found:hooks:command_not_found start (import) /usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/plugin-not-found/lib/index.js › Warning: [33mSELECT Id, Class__c, Message__c, Level__c, Reference__c, [39m › [33mCreatedDate, CreatedBy.Name FROM [39m › [33mMyTable__c WHERE CreatedDate[39m is not a sf command. 2024-05-09T08:54:04.669Z sf:@oclif/plugin-not-found:hooks:command_not_found Error: Run [1m[36msf help[39m[22m for a list of available commands. at error (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/errors/error.js:37:15) at Object.error (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:479:40) at Object.hook (file:///usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/plugin-not-found/lib/index.js:37:10) at async /usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:507:27 at async Promise.all (index 4) at async Config.runHook (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:535:9) at async Config.runCommand (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:398:19) at async run (/usr/local/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/main.js:92:16)
Anybody can help on this?
@gtiancai can you provide the version info? sf version --verbose as well as the full debug output of the failing command (using --dev-debug)?
The version is 2.40.7.
Looks like the cause is that the query returns too many records (17K), but it does not throw this error with version 2.6.9.
And I even tried to run the query in async, and then use command sf data query resume to retrieve result, got same error with this command.
Also, it will not throw error if add a limit clause to the query (I set it as LIMIT 50000, greater than 17K, weird.)
I am confused what the actual error is here.
- In your first comment, I see
The requested resource does not exist. Which indicates the query was incorrect. - In your second comment, I see the following which indicates that the
$theQueryvar was not wrapped in quotes:
› Warning: �[33mSELECT Id, Class__c, Message__c, Level__c, Reference__c, �[39m
› �[33mCreatedDate, CreatedBy.Name FROM �[39m
› �[33mMyTable__c WHERE CreatedDate�[39m is not a sf command.
- The
too many recordsmakes me think that the--bulkflag was forgotten? - I don't know why setting the LIMIT 50000 makes this work
I need all of the following to help any further:
- The full output of
sf version --verbose --json. This will be multiple lines - The actual query being used as the
$theQuery - The output that the CLI provides when you add the
--dev-debugflag to the command that is failing
I did add the flag --bulk. What I sad adding limit to the query, is just adding LIMIT 50000 to the query, no other change.
This pipeline is hosted by customer, so that I cannot provide sf version --verbose --json and --dev-debug. It just logged the CLI version: 2.40.7.
A few more thoughts from the team:
Requested resource doesn't existcan also mean they don't have permission to see the thing they queried for- It might also mean that they queried for a tooling object without using the
--use-tooling-apiflag, or the other way around - You mentioned this works locally but not in Azure, maybe it is a cross-OS issue? Linux vs Windows?
Without the actual query and some additional logs, I am afraid we won't be able to help on this.
As I said before, it works if adding a LIMIT clause. It's not related to anything from your previous post.
Where I can find the command sf data query related code?
The data query code lives in https://github.com/salesforcecli/plugin-data
See: https://github.com/salesforcecli/plugin-data/blob/main/src/commands/data/query.ts
FYI: You can find which command lives in which plugin by running the sf which command. For example sf which data query will output plugin: @salesforce/plugin-data. Most of our plugins live in the https://github.com/salesforcecli/ org. But you can also find them by looking at the "repository" or "homepage" for the plugin on npm. https://www.npmjs.com/package/@salesforce/plugin-data
This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.