Add support for `throwOnEmpty` in query function for Salesforce integration to handle zero results
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 24
- Forks
- 41
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 12
Description
Description
We need to enhance our query function in the Salesforce integration by adding support for the throwOnEmpty feature. This feature should throw an exception or handle the case where the query returns zero results.
Current Behavior
Currently, when the query function in our Salesforce integration returns zero results, the job proceeds without any indication or exception. This leads to a tedious error handling job code
Eg:
const queryResult = state.references[0][0];
const accountExists = queryResult && queryResult.totalSize > 0;
if (!accountExists) {
console.log(`Account with External ID: ${state.account.External_ID__c} not found in Salesforce`);
}
Expected Behavior
When the throwOnEmpty parameter is set to true, the query function should:
- Throw a specific exception when a query returns zero results.
- Provide a clear error message indicating that no results were found.
Steps to Reproduce
- Call the
queryfunction with parameters that will result in zero results. - Observe that no exception is thrown and the process continues as usual.
Proposed Solution
- Add a
throwOnEmptyparameter to thequeryfunction signature. - Implement logic to check the result size is bigger than 0.
- If
throwOnEmptyis true and the result set is 0, throw a specific exception with a descriptive error message.
Please feel free to reach out for any further details or clarification on this feature request. Thank you!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Salesforce integration's query function and read how its result size is currently handled. Reproduce a query with zero results, then verify that enabling throwOnEmpty produces a specific, descriptive exception while existing behavior remains unchanged when it is not enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100