Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
exoego opened this issue Aug 23, 2021 · 1 comment · May be fixed by #148
Open

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

exoego opened this issue Aug 23, 2021 · 1 comment · May be fixed by #148

Comments

@exoego
Copy link

exoego commented Aug 23, 2021

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.

@exoego exoego linked a pull request Aug 24, 2021 that will close this issue
@exoego exoego changed the title Dynalite does not validate invalid chars in ConditionExpression Dynalite does not throws __foo in ConditionExpression Aug 24, 2021
@exoego exoego changed the title Dynalite does not throws __foo in ConditionExpression Dynalite does not throws if path token starts with underscore Aug 24, 2021
@ryanblock
Copy link
Member

I haven't yet checked, but I would imagine this would also be the same for other supported special characters, namely - and . (per the Supported data types and naming rules doc). Have you looked into those yet, by chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants