You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SDK function fetchEntries does not throw an error which makes it challenging to handle the occasional API call failure on the consuming side.
Specifically in our case we use @tanstack/query to handle our data loading/caching in our applications, since the function always is resolve-ing the Promise, we aren't able to determine if the function succeeded or failed and thus the query that is using this function indicates that it was successful. Downstream this causes us potential NPEs because we're expecting an Object/Array when the query is in a successful state, not null as is returned from this function.
To Reproduce
Not including because it's not necessary, you can look at the function definition and see this is the case. I've included it below for reference.
/**
* Returns a paginated array of entries that match the given options.
*/
export async function fetchEntries(options: GetContentOptions) {
try {
const url = generateContentUrl(options);
const content = await _fetchContent(options);
if (!checkContentHasResults(content)) {
logger.error('Error fetching data. ', { url, content, options });
return null;
}
return _processContentResult(options, content);
} catch (error) {
logger.error('Error fetching data. ', error);
return null;
}
}
Expected behavior
The function should instead throw an Error in the error handling cases instead of returning null.
Screenshots
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered:
You're right, we shouldn't be swallowing errors in this way.
We'll work on throwing errors. This will need to be a major version bump due to breaking changes.
Totally understood on the major version bump, looking forward to seeing the update! We just wrote a wrapper function for now that throws an error if the response is null... which obviously has flaws but works OK in our case.
Looking forward to updating once y'all release on your end though :) Thanks!
Describe the bug
The SDK function
fetchEntries
does not throw an error which makes it challenging to handle the occasional API call failure on the consuming side.Specifically in our case we use
@tanstack/query
to handle our data loading/caching in our applications, since the function always isresolve
-ing thePromise
, we aren't able to determine if the function succeeded or failed and thus the query that is using this function indicates that it was successful. Downstream this causes us potential NPEs because we're expecting an Object/Array when the query is in a successful state, notnull
as is returned from this function.To Reproduce
Not including because it's not necessary, you can look at the function definition and see this is the case. I've included it below for reference.
Expected behavior
The function should instead throw an
Error
in the error handling cases instead of returningnull
.Screenshots
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: