-
Notifications
You must be signed in to change notification settings - Fork 0
chore: implement recommended claude code fixes #168
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
base: mainline
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -71,6 +71,7 @@ def _encode_collection_data(self, user_id: str, collection_data: CollectionData) | |||||||||||||||||||||||||||||||||||||||||||||||
| col_data = collection_data.to_dict() | ||||||||||||||||||||||||||||||||||||||||||||||||
| col_data[_PK] = self._collection_pk(user_id, collection_data.name) | ||||||||||||||||||||||||||||||||||||||||||||||||
| col_data[_SK] = self._metadata_sk() | ||||||||||||||||||||||||||||||||||||||||||||||||
| col_data["user_id"] = user_id # GSI partition key for efficient user queries | ||||||||||||||||||||||||||||||||||||||||||||||||
| return col_data | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| def get_collection(self, user_id: str, collection_name: str) -> CollectionData: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -376,20 +377,29 @@ def list_collections(self, user_id: str) -> List[CollectionData]: | |||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||
| collections = [] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # Query for all collections for this user | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Use begins_with to match USER#{user_id}#COLLECTION# | ||||||||||||||||||||||||||||||||||||||||||||||||
| response = self.table.scan( | ||||||||||||||||||||||||||||||||||||||||||||||||
| FilterExpression="begins_with(PK, :user_prefix) AND SK = :metadata", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ExpressionAttributeValues={ | ||||||||||||||||||||||||||||||||||||||||||||||||
| ":user_prefix": f"USER#{user_id}#COLLECTION#", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ":metadata": self._metadata_sk(), | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Query GSI for all collections for this user | ||||||||||||||||||||||||||||||||||||||||||||||||
| response = self.table.query( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical Bug: This query will return ALL items for the user, not just collection metadata! The GSI only filters by
Solution: Add a filter expression: response = self.table.query(
IndexName="UserCollectionsIndex",
KeyConditionExpression="user_id = :user_id",
FilterExpression="SK = :metadata",
ExpressionAttributeValues={
":user_id": user_id,
":metadata": self._metadata_sk()
},
)Note: |
||||||||||||||||||||||||||||||||||||||||||||||||
| IndexName="UserCollectionsIndex", | ||||||||||||||||||||||||||||||||||||||||||||||||
| KeyConditionExpression="user_id = :user_id", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ExpressionAttributeValues={":user_id": user_id}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Missing pagination handling This query doesn't handle pagination. DynamoDB query operations can return a maximum of 1 MB of data per call. If a user has many collections, the response may be paginated and include a
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| for item in response.get("Items", []): | ||||||||||||||||||||||||||||||||||||||||||||||||
| collection = CollectionData.from_dict(item) | ||||||||||||||||||||||||||||||||||||||||||||||||
| collections.append(collection) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # Handle pagination if there are more results | ||||||||||||||||||||||||||||||||||||||||||||||||
| while "LastEvaluatedKey" in response: | ||||||||||||||||||||||||||||||||||||||||||||||||
| response = self.table.query( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||||||||||||||||||||||||||||||||||||||||||||||||
| IndexName="UserCollectionsIndex", | ||||||||||||||||||||||||||||||||||||||||||||||||
| KeyConditionExpression="user_id = :user_id", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ExpressionAttributeValues={":user_id": user_id}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ExclusiveStartKey=response["LastEvaluatedKey"], | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| for item in response.get("Items", []): | ||||||||||||||||||||||||||||||||||||||||||||||||
| collection = CollectionData.from_dict(item) | ||||||||||||||||||||||||||||||||||||||||||||||||
| collections.append(collection) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| return collections | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| def get_collection_objects( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.