lore-aws: return proper error for invalid dynamo query instead of panic#54
Open
subbareddypalagiri wants to merge 1 commit into
Open
lore-aws: return proper error for invalid dynamo query instead of panic#54subbareddypalagiri wants to merge 1 commit into
subbareddypalagiri wants to merge 1 commit into
Conversation
6b22a1d to
d9fc475
Compare
Collaborator
|
Seems this PR needs a bit of cleaning up or rebasing |
d9fc475 to
04e4234
Compare
There was a problem hiding this comment.
Pull request overview
This PR adjusts DynamoDB query pagination behavior in lore-aws to avoid panicking on an invalid query configuration and instead surface an error to callers.
Changes:
- Added a validation guard in
query_paginatedfor the invalid combination ofSelect::Countwithlimit. - Removed the feature-flag gate (
LORE_ENABLE_QUERY_PAGINATION) so pagination follow-up queries are no longer conditional on an env var. - Updated pagination continuation logic/comments accordingly.
Comments suppressed due to low confidence (1)
lore-aws/src/dynamodb.rs:657
- This change removes the LORE_ENABLE_QUERY_PAGINATION feature flag and makes pagination behavior unconditional whenever LastEvaluatedKey is present. That’s a behavioral/operational change beyond “replace panic with error” described in the PR metadata; please either (a) update the PR description/scope (or split into a separate PR), or (b) reintroduce the flag if it’s still needed for rollout/debugging.
if let Some(last_evaluated_key) = r.last_evaluated_key
&& !last_evaluated_key.is_empty()
&& (query.limit().is_none()
|| matches!(query.select(), Some(Select::Count))
|| query.limit().is_some_and(|l| output.count < l))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+569
to
+575
| if matches!(query.select(), Some(Select::Count)) && query.limit().is_some() { | ||
| return Err(crate::aws_error::AwsError::AwsSdkError(aws_sdk_dynamodb::error::SdkError::construction_failure("Combining Select::Count and a limit is disallowed for paginated queries"))); | ||
| } | ||
|
|
||
| if matches!(query.select(), Some(Select::Count)) && query.limit().is_some() { | ||
| panic!("Combining Select::Count and a limit is disallowed for paginated queries to avoid fetching count one row at a time."); | ||
| } |
04e4234 to
3de3cf2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changed the panic condition to instead return a proper error.