Skip to content

Commit 10ac125

Browse files
committed
fixed get repos
1 parent 5aebb45 commit 10ac125

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

socketdev/repos/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ class Repos:
7070
def __init__(self, api):
7171
self.api = api
7272

73-
def get(self, org_slug: str, **kwargs) -> dict[str, List[RepositoryInfo]]:
73+
def get(self, org_slug: str, **kwargs) -> dict[str, list[dict] | int]:
7474
query_params = kwargs
7575
path = "orgs/" + org_slug + "/repos"
7676

77-
if query_params: # Only add query string if we have parameters
77+
if query_params:
7878
path += "?"
7979
for param in query_params:
8080
value = query_params[param]
@@ -85,8 +85,14 @@ def get(self, org_slug: str, **kwargs) -> dict[str, List[RepositoryInfo]]:
8585

8686
if response.status_code == 200:
8787
raw_result = response.json()
88-
result = {key: [RepositoryInfo.from_dict(repo) for repo in repos] for key, repos in raw_result.items()}
89-
return result
88+
per_page = int(query_params.get("per_page", 30))
89+
90+
# TEMPORARY: Handle pagination edge case where API returns nextPage=1 even when no more results exist
91+
next_page = raw_result["nextPage"]
92+
if next_page != 0 and len(raw_result["results"]) < per_page:
93+
next_page = 0
94+
95+
return {"results": raw_result["results"], "nextPage": next_page}
9096

9197
error_message = response.json().get("error", {}).get("message", "Unknown error")
9298
log.error(f"Error getting repositories: {response.status_code}, message: {error_message}")

0 commit comments

Comments
 (0)