You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the store.list method with multiple filters in the Sentio SDK's MemoryDatabase, we've encountered two distinct issues that break our processor tests:
Two valid filters return no results: When combining two individually working filters, the combination produces an empty result set even when matching records exist
Error when filtering with relation IDs: When filtering on a relation ID field alongside another filter, an error is thrown: TypeError: Cannot read properties of undefined (reading 'stringValue')
Run the specific test case that demonstrates the issue:
sentio test# there's no test filter option, but it's the "Stake with existing subscription" test case
The test is located at ./src/tests/multi-rewards/tests/stake.test.ts. The problematic code is in the event handler for onEventStakeEvent in the multi-rewards processor, where it attempts to fetch active subscriptions.
The problematic code pattern is:
// Get all active subscriptions for this user using listconstactiveSubscriptions=awaitstore.list(MRUserSubscription,[// Scenario 1: Two valid filters return empty results{field: "user_address",op: "=",value: userAddress},{field: "is_currently_subscribed",op: "=",value: true},// Scenario 2: Throws error with relation ID field// { field: "userID", op: "=", value: userAddress },// { field: "is_currently_subscribed", op: "=", value: true },]);
When multiple valid filters are provided, records matching ALL filters should be returned
Filtering on relation ID fields should work correctly and not throw errors
Actual Behavior
Scenario 1: When applying two valid filters together (both of which work individually), an empty array is returned even when matching records exist
Scenario 2: When using a relation ID field (userID) in a filter with another filter, the following error is thrown:
TypeError [Error]: Cannot read properties of undefined (reading 'stringValue')
at equal (/node_modules/@sentio/sdk/src/testing/memory-database.ts:256:13)
Analysis
After debugging, we found:
Each filter works correctly when applied individually
The issue appears to be in how the filter or equal functions in the MemoryDatabase handle multiple filters and relation ID fields
The error in Scenario 2 suggests type mismatches when comparing field values for different field types
Current Workaround
We've implemented a workaround by applying filters sequentially in JavaScript:
// Get subscriptions by user firstconstuserSubscriptions=awaitstore.list(MRUserSubscription,[{field: "user_address",op: "=",value: userAddress}]);// Then filter manually in JavaScriptconstactiveSubscriptions=userSubscriptions.filter(subscription=>subscription.is_currently_subscribed===true);
Environment Information
Sentio SDK Version: 2.57.8
Node.js Version: v22.12.0
Additional Notes
This bug may be related to type handling in the filter and equal functions in the MemoryDatabase implementation, specifically around how it handles:
Applying multiple filters in combination
Comparing fields of different types (strings, booleans, relation IDs)
The text was updated successfully, but these errors were encountered:
Description
When using the
store.list
method with multiple filters in the Sentio SDK'sMemoryDatabase
, we've encountered two distinct issues that break our processor tests:TypeError: Cannot read properties of undefined (reading 'stringValue')
Reproduction Steps
You can reproduce both issues using our buggy-filter-scenarios branch.
To reproduce:
The test is located at
./src/tests/multi-rewards/tests/stake.test.ts
. The problematic code is in the event handler foronEventStakeEvent
in the multi-rewards processor, where it attempts to fetch active subscriptions.The problematic code pattern is:
The schema for the entity being filtered is:
Expected Behavior
Actual Behavior
userID
) in a filter with another filter, the following error is thrown:Analysis
After debugging, we found:
filter
orequal
functions in the MemoryDatabase handle multiple filters and relation ID fieldsCurrent Workaround
We've implemented a workaround by applying filters sequentially in JavaScript:
Environment Information
Additional Notes
This bug may be related to type handling in the
filter
andequal
functions in theMemoryDatabase
implementation, specifically around how it handles:The text was updated successfully, but these errors were encountered: