From 43aa595433124d796eae66e7439565bdefb430a4 Mon Sep 17 00:00:00 2001 From: George Antonopoulos Date: Wed, 14 Jan 2026 19:34:51 +0000 Subject: [PATCH] Fix review issues in pagination implementation - Move `import re` to top of file (was inline in function) - Add page parameter validation (page >= 1) - Fix parameter order bug in search_utils.py (was swapped) Co-Authored-By: Claude Opus 4.5 --- basecamp_client.py | 4 +++- search_utils.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/basecamp_client.py b/basecamp_client.py index e6f15cf..111aad6 100644 --- a/basecamp_client.py +++ b/basecamp_client.py @@ -1,4 +1,5 @@ import os +import re import requests from dotenv import load_dotenv @@ -422,6 +423,8 @@ class BasecampClient: - total_count: total number of comments (from X-Total-Count header) - next_page: next page number if available, None otherwise """ + if page < 1: + raise ValueError("page must be >= 1") endpoint = f"buckets/{project_id}/recordings/{recording_id}/comments.json" response = self.get(endpoint, params={"page": page}) if response.status_code == 200: @@ -435,7 +438,6 @@ class BasecampClient: if 'rel="next"' in link_header: # Extract page number from Link header # Format: ; rel="next" - import re match = re.search(r'page=(\d+).*rel="next"', link_header) if match: next_page = int(match.group(1)) diff --git a/search_utils.py b/search_utils.py index 6906c26..0a5f079 100644 --- a/search_utils.py +++ b/search_utils.py @@ -467,7 +467,7 @@ class BasecampSearch: try: # If both recording_id and bucket_id are provided, get comments for that specific recording if recording_id and bucket_id: - result = self.client.get_comments(recording_id, bucket_id) + result = self.client.get_comments(bucket_id, recording_id) comments = result["comments"] # Otherwise we can't search across all comments as there's no endpoint for that else: