Skip to content

Dynalite does not throws if path token starts with underscore #147

@exoego

Description

@exoego

Summary

DynamoDB and DynamoDB-local throws ValidationException if attribute name inConditionExpression starts with _.
However, Dynalite does not throw and PutItem succeed.

Expectation

Dynalite should throw, so users can identity invalid chars and escape them using ExpressionAttributeNames.

Repro

DynamoDB Local

docker run -d -p 8000:8000 amazon/dynamodb-local 

aws dynamodb create-table \
    --endpoint http://localhost:8000 \
    --table-name MusicCollection \
    --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

aws dynamodb put-item --endpoint http://localhost:8000 --table-name MusicCollection \
  --item '{"Artist": {"S": "Foo"}, "SongTitle": {"S": "Bar"}, "__typename": {"S": "SongItem"}}' \
  --condition-expression "__typename <> :__typename" \
  --expression-attribute-values '{":__typename":{"S":"SongItem"}}'

This wil throwAn error occurred (ValidationException) when calling the PutItem operation: Invalid ConditionExpression: Syntax error; token: "_", near: "__".

Dynalite

docker run -d -p 8000:8000  dimaqq/dynalite:latest

aws dynamodb create-table \
    --endpoint http://localhost:8000 \
    --table-name MusicCollection \
    --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S \
    --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

aws dynamodb put-item --endpoint http://localhost:8000 --table-name MusicCollection \
  --item '{"Artist": {"S": "Foo"}, "SongTitle": {"S": "Bar"}, "__typename": {"S": "SongItem"}}' \
  --condition-expression "__typename <> :__typename" \
  --expression-attribute-values '{":__typename":{"S":"SongItem"}}'

This will succeed, but it should fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions