fix(dynamodb): honor legacy QueryFilter parameter#1
Merged
Conversation
The Query handler reads only FilterExpression — it silently dropped the legacy QueryFilter parameter, returning unfiltered results. The AWS Java SDK v1 Document API still emits QueryFilter when callers use QuerySpec.withQueryFilters(...), and a fair amount of existing Java code still does. Without honoring it, type-discriminated reads (e.g. "fetch only AUDIO_GATEWAY rows" against a polymorphic device table) returned all rows, then blew up downstream when callers cast to the wrong concrete type. ScanFilter (the Scan-side equivalent with the same wire format) was already supported in handleScan/scan(...). This change mirrors that plumbing for Query: parse QueryFilter in the JSON handler, thread it through to DynamoDbService.query, and apply it post-FilterExpression via matchesScanFilter (the wire format is identical). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes a silent bug where
Queryrequests carrying the legacyQueryFilterparameter (rather thanFilterExpression) returned unfiltered results.Repro
Before: returns rows of every type for that org. After: returns only
AUDIO_GATEWAYrows.Why this matters
The AWS Java SDK v1 Document API still emits
QueryFilterwhen callers useQuerySpec.withQueryFilters(...). A lot of existing Java code does — including older Rhombus services. Without honoringQueryFilter, type-discriminated reads against polymorphic tables (e.g. "fetch only AUDIO_GATEWAY rows" from a Devices table that mixes camera/audio-gateway/door rows) returned every row, and the caller then blew up castingCameraTypetoAudioGatewayType.What changed
Scanalready supports the legacyScanFilterparameter (same wire format) inhandleScan/scan(...). This PR adds the symmetric plumbing forQuery:DynamoDbJsonHandler.handleQueryreadsQueryFilterfrom the request and passes it through.DynamoDbService.queryaccepts a newJsonNode queryFilterparameter and applies it post-FilterExpressionviamatchesScanFilter— the wire format is identical toScanFilter.query(...)overloads passnullfor the new parameter to preserve existing call sites.Test plan
FilterExpressionshould be unaffected (new branch only fires whenQueryFilteris present, applied afterFilterExpression)🤖 Generated with Claude Code
Note
Medium Risk
Changes
Queryresult filtering semantics when legacyQueryFilteris present, which can alter returned items for some callers. Scope is limited and backwards-compatible for existing call sites that don’t sendQueryFilter.Overview
Fixes DynamoDB emulator
Queryhandling to honor the legacyQueryFilterrequest parameter (emitted by AWS SDK v1 Document API), preventing silently unfiltered query results.DynamoDbJsonHandler.handleQuerynow parses and forwardsQueryFilter, andDynamoDbService.queryadds a new overload that applies the filter after anyFilterExpressionusing the existingmatchesScanFilterlogic; existingquery(...)overloads passnullto preserve current behavior.Reviewed by Cursor Bugbot for commit e4a49ad. Bugbot is set up for automated code reviews on this repo. Configure here.