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 - unexpected values set in AttributeValue #814

Open
gchudnov opened this issue Apr 29, 2022 · 2 comments
Open

DynamoDB - unexpected values set in AttributeValue #814

gchudnov opened this issue Apr 29, 2022 · 2 comments

Comments

@gchudnov
Copy link

gchudnov commented Apr 29, 2022

Hi,

When making a batchGetItem reqest, a reponse received from the server is transformed to an unexpected BatchGetItemResponse.ReadOnly-response (with some redundant fields).

For example, for the following response from the server:

{
  "Responses": {
    "History": [
      {
        "key": {
          "S": "V9"
        },
        "version": {
          "N": "-1049669123"
        },
        "records": {
          "S": "123"
        },
        "value": {
          "S": "yqKwfeak1sVV"
        }
      }
    ]
  },
  "UnprocessedKeys": {}
}

the attribute:

        "key": {
          "S": "V9"
        },

is transformed to the following AttributeValuein zio-aws:

0 = {Tuple2@9813} (country,zio.aws.dynamodb.model.AttributeValue$Wrapper@33aef772)
 _2 = {AttributeValue$Wrapper@9821} zio.aws.dynamodb.model.AttributeValue$Wrapper@33aef772
  s = {Some@9824} Some(V9)
  n = {None$@9825} None
  b = {None$@9825} None
  ss = {Some@9826} Some(List())
  ns = {Some@9827} Some(List())
  bs = {Some@9828} Some(List())
  m = {Some@9829} Some(Map())
  l = {Some@9830} Some(List())
  nul = {None$@9825} None
  bool = {None$@9825} None

^
here we can see that all Iterables, like SS, NS, BS, M, etc. are set to Some(List()), Some(Map()).

the expected behavior is to set them to None, since they were absent in the response from the server.

@vigoo
Copy link
Collaborator

vigoo commented May 14, 2022

Interseting, thank you for reporting. I will take a look, but my guess is that in the Java SDK level these are not nulls either but empty collections. Not sure if treating those everywhere as None is a valid solution (think of every AWS service's every operation)

@joprice
Copy link

joprice commented Aug 4, 2023

@vigoo You are right. The docs say they will never return null:

This method will never return null. If you would like to know whether the service returned this field (so that you can differentiate between null and empty), you can use the hasL() method.

To wrap in an optional, you'd want to call hasL() first to check if the field is set.

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

No branches or pull requests

3 participants