Skip to content

Commit

Permalink
Implement null check for the 'findPaginatedResourcePath' function
Browse files Browse the repository at this point in the history
Previously the `deepFindPathToProperty` function would occasionally fail with `TypeError: Cannot read properties of null (reading 'hasOwnProperty')`. This change fixes that by adding a null check to the `findPaginatedResourcePath` function.

Resolves octokit#58
  • Loading branch information
igwejk committed Sep 20, 2024
1 parent 686401b commit c8993d1
Showing 1 changed file with 2 additions and 2 deletions.
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) {
throw new MissingPageInfo(responseData);
}
return paginatedResourcePath;
Expand Down

0 comments on commit c8993d1

Please sign in to comment.