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

DynamoDB enhanced creates invalid requests #2243

Closed
productivityindustries opened this issue Jan 15, 2021 · 2 comments · Fixed by #2255
Closed

DynamoDB enhanced creates invalid requests #2243

productivityindustries opened this issue Jan 15, 2021 · 2 comments · Fixed by #2255
Labels
bug This issue is a bug. dynamodb-enhanced

Comments

@productivityindustries
Copy link

When using a mapped bean class having a Map attribute, creating or updating the map with a null value produces an invalid PutObjectRequest/UpdateObjectRequest

Describe the bug

Bean:

@DynamoDbBean
public static class Book {

  private String id;
  private Map<String, String> map;

  public Book() { }
  public Book(String id) { setId(id); }

  @DynamoDbPartitionKey public String getId() {return id;}
  public void setId(String id) {this.id = id;}
  public Map<String, String> getMap() {return map;}
  public void setMap(Map<String, String> map) {this.map = map;}
}

Use a DynamoDbTable<Book> to put an item:

    Book b = new Book(id);
    b.setMap(Collections.singletonMap("a", null));
    TABLE.putItem(b);

fails with DynamoDbException: Supplied AttributeValue is empty.
The created PutObjectRequest is:
PutItemRequest(TableName=books, Item={id=AttributeValue(S=id), map=AttributeValue(M={a=AttributeValue()})})

The AttributeValue of map.a is invalid.

The same process using low-level client works, using a null AttributeValue:

    DB.putItem(b -> b
      .tableName("books")
      .item(new HashMap<String, AttributeValue>() {{
        put("id", AttributeValue.builder().s(id).build());
        put("metadata", AttributeValue.builder()
          .m(Collections.singletonMap("a", AttributeValue.builder().nul(true).build()))
          .build());
      }})
    );

A similar behavior is present on update operations.

Expected Behavior

The enhanced request should be valid, having a null Attribute value.

tested on

  • AWS Java SDK version 2.15.65
  • JDK version used: 1.8
@productivityindustries productivityindustries added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 15, 2021
@debora-ito
Copy link
Member

Hi @productivityindustries I can reproduce the issue. Marking as a bug.

@debora-ito debora-ito added dynamodb-enhanced and removed needs-triage This issue or PR still needs to be triaged. labels Jan 16, 2021
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

aws-sdk-java-automation added a commit that referenced this issue Nov 10, 2022
…e44d22303

Pull request: release <- staging/7407366d-08d6-4003-86c2-7c8e44d22303
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. dynamodb-enhanced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants