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

fix: add null check in deepFindPathToProperty function #137

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/object-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const isObject = (value: any) =>
Object.prototype.toString.call(value) === "[object Object]";

function findPaginatedResourcePath(responseData: any): string[] {
const paginatedResourcePath = deepFindPathToProperty(
const paginatedResourcePath: string[] | null = deepFindPathToProperty(
responseData,
"pageInfo",
);
if (paginatedResourcePath.length === 0) {
if (paginatedResourcePath === null || paginatedResourcePath.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this line fix #58? The stacktrace and the description looks like it happens in deepFindPathToProperty implementation, not for the returned value.

This causes currentValue.hasOwnProperty(searchProp) to throw TypeError: Cannot read properties of null (reading 'hasOwnProperty') error.

if (currentValue.hasOwnProperty(searchProp)) {
return currentPath;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw new MissingPageInfo(responseData);
}
return paginatedResourcePath;
Expand Down