aristidb / aws

Amazon Web Services for Haskell
BSD 3-Clause "New" or "Revised" License
239 stars 108 forks source link

Fix parsing bug with table description creation date #223

Closed MichaelXavier closed 7 years ago

MichaelXavier commented 7 years ago

It appears that sometimes aws returns CreationDateTime in floating point unix epox format (or this was a regression, but I found no evidence for this in the git blame).

When running tests recently I got the following error:

JsonProtocolError (Object (fromList [("TableDescription",Object (fromList [("TableSizeBytes",Number 0.0),("AttributeDefinitions",Array [Object (fromList [("AttributeType",String "S"),("AttributeName",String "_k")]),Object (fromList [("AttributeType",String "N"),("AttributeName",String "_t")])]),("ProvisionedThroughput",Object (fromList [("ReadCapacityUnits",Number 10.0),("WriteCapacityUnits",Number 10.0),("NumberOfDecreasesToday",Number 0.0)])),("TableStatus",String "CREATING"),("TableArn",String "xxxxxxxxxxxxxxx"),("KeySchema",Array [Object (fromList [("KeyType",String "HASH"),("AttributeName",String "_k")]),Object (fromList [("KeyType",String "RANGE"),("AttributeName",String "_t")])]),("CreationDateTime",Number 1.486669270281e9),("TableId",String "xxxxxxxxxxxxxxxxxxxx"),("ItemCount",Number 0.0),("TableName",String "xxxxxxxxxxx")]))])) "Floating number specified for Integer: 1.486669270281e9"

Because we're using posix second conversions anyways, it seems perfectly fine to round (or truncate, floor, ceil, whatever) the floating point to the latest integer before conversion. This immediately resolved the problem for me.

MichaelXavier commented 7 years ago

Hold on, I've noticed theres a few other static fields that have datetimes.

MichaelXavier commented 7 years ago

There we go.