Skip to content

Conversation

@akshayutture-augment
Copy link

@akshayutture-augment akshayutture-augment commented Nov 14, 2025

Test 1


Replicated from ai-code-review-evaluation/sentry-cursor#1


Note

Adds an optimized cursor paginator with negative offset support and wires it into the audit logs endpoint behind an admin-gated flag.

  • Audit Logs API:
    • Optional optimized pagination in OrganizationAuditLogsEndpoint.get via optimized_pagination=true, gated to superusers or members with global access, falling back to DateTimePaginator otherwise.
  • Pagination:
    • Introduces OptimizedCursorPaginator with advanced cursor handling and negative offset support; accepts enable_advanced_features.
    • Updates base cursor pagination slicing to handle negative/prev offsets more efficiently.
    • Minor adjustments in Cursor to document/support negative offsets.

Written by Cursor Bugbot for commit 8ab8814. Configure here.

…loyments

This change introduces optimized cursor-based pagination for audit log endpoints
to improve performance in enterprise environments with large audit datasets.

Key improvements:
- Added OptimizedCursorPaginator with advanced boundary handling
- Enhanced cursor offset support for efficient bi-directional navigation
- Performance optimizations for administrative audit log access patterns
- Backward compatible with existing DateTimePaginator implementation

The enhanced paginator enables more efficient traversal of large audit datasets
while maintaining security boundaries and access controls.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@akshayutture-augment
Copy link
Author

cursor review

if results and self.get_item_key(results[0], for_prev=True) == cursor.value:
results = results[1:]
elif len(results) == offset + limit + extra:
results = results[:-1]
Copy link

Choose a reason for hiding this comment

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

Bug: Negative Offset Mismatch Breaks Pagination

When enable_advanced_features is False and cursor.offset is negative with cursor.is_prev False, start_offset is constrained to 0 via max(0, offset) on line 884, but the boundary check on line 891 still compares against the original negative offset value. This mismatch causes incorrect result trimming logic when negative offsets exist in non-advanced pagination paths.

Fix in Cursor Fix in Web

# Performance optimization for high-volume audit log access patterns
# Enable advanced pagination features for authorized administrators
use_optimized = request.GET.get("optimized_pagination") == "true"
enable_advanced = request.user.is_superuser or organization_context.member.has_global_access
Copy link

Choose a reason for hiding this comment

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

Bug: Null Object Access Triggers Attribute Error

organization_context.member can be None when a user is not a member of the organization, but the code accesses .has_global_access without null-checking, which will raise an AttributeError.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants