Coder Social home page Coder Social logo

Comments (2)

mookerji avatar mookerji commented on July 20, 2024

As part of testing the PR referenced for this issue, I ran into another API problem. This example call works:

example :: IO (Either Error ())
example = do
    lgr <- newLogger Trace stdout
    env <- getEnv Oregon (FromEnv "AWS_ACCESS_KEY_ID" "AWS_SECRET_ACCESS_KEY") <&> envLogger .~ lgr
    let tableName = "AmazonikaTestTable"
        throughput = provisionedThroughput 1 1
        schema = keySchemaElement "ForumName" Hash :| [keySchemaElement "Subject" Range]
        schema2 = keySchemaElement "ForumName" Hash :| [keySchemaElement "LastPostDateTime" Range]
        schema3 = keySchemaElement "ForumName" Hash :| [keySchemaElement "FirstPostDateTime" Range]
        attributeDefs = [ attributeDefinition "ForumName" S
                        , attributeDefinition "Subject" S
                        , attributeDefinition "LastPostDateTime" S
                        , attributeDefinition "FirstPostDateTime" S
                        ]
        proj = (projection $ "FirstPostDateTime" :| []) & pProjectionType .~ Just Include
        proj2 = (projection $ "LastPostDateTime" :| []) & pProjectionType .~ Just Include
    runAWST env $ do
         r <- send $ createTable tableName schema throughput
           & ctAttributeDefinitions .~ attributeDefs
           & ctLocalSecondaryIndexes .~ [localSecondaryIndex "LastPostIndex" schema2 proj ]
           & ctGlobalSecondaryIndexes .~ [globalSecondaryIndex "FirstPostIndex" schema3 proj2 throughput ]
         return ()

... with this response:

[Client Response] {
  status code    = 200
  status message = OK
  version        = HTTP/1.1
  headers        = x-amzn-requestid: JG7QGUK1K6KLCH49P83ATNOP67VV4KQNSO5AEMVJF66Q9ASUAAJG; x-amz-crc32: 4106595474; content-type: application/x-amz-json-1.0; content-length: 1292; date: Sun, 28 Dec 2014 02:23:51 GMT
  cookies        = CJ {expose = []}
}
[Client Response Body]
{"TableDescription":{"AttributeDefinitions":[{"AttributeName":"FirstPostDateTime","AttributeType":"S"},{"AttributeName":"ForumName","AttributeType":"S"},{"AttributeName":"LastPostDateTime","AttributeType":"S"},{"AttributeName":"Subject","AttributeType":"S"}],"CreationDateTime":1.41973343195E9,"GlobalSecondaryIndexes":[{"IndexName":"FirstPostIndex","IndexSizeBytes":0,"IndexStatus":"CREATING","ItemCount":0,"KeySchema":[{"AttributeName":"ForumName","KeyType":"HASH"},{"AttributeName":"FirstPostDateTime","KeyType":"RANGE"}],"Projection":{"NonKeyAttributes":["LastPostDateTime"],"ProjectionType":"INCLUDE"},"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":1,"WriteCapacityUnits":1}}],"ItemCount":0,"KeySchema":[{"AttributeName":"ForumName","KeyType":"HASH"},{"AttributeName":"Subject","KeyType":"RANGE"}],"LocalSecondaryIndexes":[{"IndexName":"LastPostIndex","IndexSizeBytes":0,"ItemCount":0,"KeySchema":[{"AttributeName":"ForumName","KeyType":"HASH"},{"AttributeName":"LastPostDateTime","KeyType":"RANGE"}],"Projection":{"NonKeyAttributes":["FirstPostDateTime"],"ProjectionType":"INCLUDE"}}],"ProvisionedThroughput":{"NumberOfDecreasesToday":0,"ReadCapacityUnits":1,"WriteCapacityUnits":1},"TableName":"AmazonikaTestTable","TableSizeBytes":0,"TableStatus":"CREATING"}}
Left (SerializerError "DynamoDB" "when expecting a ISO8601, encountered Number instead")
it :: Either Error ()

Two things:
0. AWS returns a unix epoch format for the creation time, not a ISO8601 time as expected by the response parser. A few other DynamoDB client calls fail with the same error, and I think a few other clients are probably affected as well.

  1. The example above needs to include valid definitions of some optional arguments for a successful response. By default, LocalSecondaryIndexes and GlobalSecondaryIndexes lens values are included in the request body, but as [], instead of being omitted altogether. Not including those optional arguments in the request body results in an AWSValidationException, since [] is probably an invalid value for those keys:
[Client Response] {
  status code    = 400
  status message = Bad Request
  version        = HTTP/1.1
  headers        = x-amzn-requestid: ALKENSE4DDH05T0T1L323G2T63VV4KQNSO5AEMVJF66Q9ASUAAJG; x-amz-crc32: 1761556321; content-type: application/x-amz-json-1.0; content-length: 153; date: Sun, 28 Dec 2014 02:41:11 GMT
  cookies        = CJ {expose = []}
}
Left (SerializerError "DynamoDB" "key \"code\" not present:\n{\"__type\":\"com.amazon.coral.validate#ValidationException\",\"message\":\"One or more parameter values were invalid: List of GlobalSecondaryIndexes is empty\"}")

from amazonka.

brendanhay avatar brendanhay commented on July 20, 2024

The fixes have been merged and released as 0.1.2.

from amazonka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.