Skip to content

Dynamodb V4: Table Scan Count Operation not possible with FilterExpression any more #4324

@wirmar

Description

@wirmar

Describe the bug

With a Table table, when calling table.Scan(scanConfig).Count with a scanConfig that contains only a FilterExpression, the SDK throws the error:

Amazon.DynamoDBv2.AmazonDynamoDBException: Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {ScanFilter} Expression parameters: {FilterExpression} ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.

With the AWSSDK v3 (previously using <PackageVersion Include="AWSSDK.DynamoDBv2" Version="3.7.5.20" />) this was possible without getting the error. The only difference in our code is creating the Table via TableBuilder instead of Table.LoadTable.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The count is returned.

Current Behavior

An exception is thrown:

Amazon.DynamoDBv2.AmazonDynamoDBException: Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {ScanFilter} Expression parameters: {FilterExpression} ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.

Reproduction Steps

        using var client = new AmazonDynamoDBClient(region);
        var config = new TableConfig(tableName)
        {
            Conversion = DynamoDBEntryConversion.V2
        };

        var tableBuilder = new TableBuilder(client, config);
        tableBuilder.AddHashKey(hashKey, DynamoDBEntryType.String);
        var table = tableBuilder.Build();
        var scanConfig = new ScanOperationConfig();
        scanConfig.FilterExpression = new Expression
            {
                ExpressionStatement = "Views >= :num",
                ExpressionAttributeValues = new Dictionary<string, DynamoDBEntry>
                {
                    {":num", new Primitive("10", true)}
                }
            };
        var count =table.Scan(scanConfig).Count;

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.DynamoDBv2 4.0.12.1

Targeted .NET Platform

.NET 10

Operating System and version

AmazonLinux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.dynamodbpotential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions