fix: add warning logs for 10k aggregation limit#2067
Conversation
WalkthroughThis PR centralizes the OpenSearch ChangesTerms aggregation limit centralization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/api/connectors.py`:
- Around line 126-131: The warning logs in the connector aggregation path
hardcode “10k” instead of reflecting OPENSEARCH_TERMS_AGG_LIMIT, so update the
warning messages in the relevant connector aggregation checks (including the
code around connector_file_id_buckets and the other matching warning calls) to
use the shared constant’s value in the message. Make the change consistently
across all four warnings so the log text stays accurate if
OPENSEARCH_TERMS_AGG_LIMIT changes, using the existing logger.warning calls and
related connector_type/returned_count context.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2954d494-3190-4c55-b005-01dcd16a8f06
📒 Files selected for processing (1)
src/api/connectors.py
| if len(connector_file_id_buckets) == OPENSEARCH_TERMS_AGG_LIMIT: | ||
| logger.warning( | ||
| "Connector file ID aggregation hit 10k limit - results may be truncated", | ||
| connector_type=connector_type, | ||
| returned_count=len(connector_file_ids), | ||
| ) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Warning messages hardcode "10k" instead of using the constant.
All four warning log strings (lines 128, 143, 155, 209) embed the literal "10k" even though the PR's purpose is to centralize the limit into OPENSEARCH_TERMS_AGG_LIMIT. If the constant is ever changed, the logs will be misleading. Use the constant value in the message instead.
🔧 Suggested fix
- "Connector file ID aggregation hit 10k limit - results may be truncated",
+ "Connector file ID aggregation hit %(limit)d limit - results may be truncated",
+ limit=OPENSEARCH_TERMS_AGG_LIMIT,
connector_type=connector_type,
returned_count=len(connector_file_ids),Apply the same pattern to the other three warning calls (lines 143, 155, 209).
Also applies to: 141-158, 207-212
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/api/connectors.py` around lines 126 - 131, The warning logs in the
connector aggregation path hardcode “10k” instead of reflecting
OPENSEARCH_TERMS_AGG_LIMIT, so update the warning messages in the relevant
connector aggregation checks (including the code around
connector_file_id_buckets and the other matching warning calls) to use the
shared constant’s value in the message. Make the change consistently across all
four warnings so the log text stays accurate if OPENSEARCH_TERMS_AGG_LIMIT
changes, using the existing logger.warning calls and related
connector_type/returned_count context.
Temporarily fixes Issue #1548
Added warning logs to alert operators when OpenSearch terms aggregations
hit the 10,000 bucket limit in connector sync operations. This helps
detect potential data truncation issues in workspaces with >10k unique
document IDs, filenames, or connector file IDs.
Affected functions:
get_synced_file_ids_for_connector(): Warns when connector_file_id,
document_id, or filename aggregations reach the limit
get_synced_id_to_filename_map(): Warns when document_id aggregation
reaches the limit
This is an interim solution to surface the issue. A future enhancement
should implement composite aggregation with pagination to handle
arbitrarily large result sets without truncation.
Related: Connector sync may miss documents when workspace exceeds 10k
unique values per field
Summary by CodeRabbit