-
Notifications
You must be signed in to change notification settings - Fork 626
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 - PutItem, returns (nil, err) on ConditionalCheckFailedException. #2183
Comments
Hi @heathedavid, Thanks for bringing this to our attention. The value isn't printed because of a deserialization issue. _, err = client.PutItem(context.TODO(), input, func(options *dynamodb.Options) {
options.ClientLogMode = aws.LogResponseWithBody
}) Thanks, |
Hi, After looking a bit into this, there is no deserialization issue.
This is the intended behavior - this follows the golang idiom of a function's returned values and errors being mutually exclusive. So in this particular case, the failed items were added as a field on the error response itself - see the new definition of type ConditionalCheckFailedException struct {
Message *string
ErrorCodeOverride *string
Item map[string]AttributeValue // this is new
} In practice, this means the new field if err != nil {
var err1 *types.ConditionalCheckFailedException
if errors.As(err, &err1) {
// err1.Item is usable here
}
} Thanks, |
|
Thank you - That makes perfect sense it is in the Error - I have it
working...
…On Mon, Jul 17, 2023 at 5:33 PM github-actions[bot] < ***@***.***> wrote:
|
Sorry for the informal bug report...
Again using the latest GO SDK and have found an issue when trying to
write.a String Set.
The fields looks like:
// ForecastMethods contains the set of forecast methods that have been
generated for
// the timeseries. Note this is stored as a String Set in DynamoDB
ForecastMethods []string `dynamodbav:"forecast_methods,stringset,omitempty"
json:"forecast_methods"`
If the field is nil it will not be persisted to dynamodb - however if it is
an empty array it is written - with type null If this happens I get an
error when I try to add an element to the set
If you require a complete example, please let me know.
David
…On Tue, Jul 25, 2023 at 10:13 AM David Heath ***@***.***> wrote:
Thank you - That makes perfect sense it is in the Error - I have it
working...
On Mon, Jul 17, 2023 at 5:33 PM github-actions[bot] <
***@***.***> wrote:
>
|
Describe the bug
As of Jun 30 2023 the press release:
https://aws.amazon.com/about-aws/whats-new/2023/06/amazon-dynamodb-cost-failed-conditional-writes/
It appears if PutItem fails with a ConditionalCheckFailedException a copy of the items wil be returned (if the appopriate flag is set on the input).
Upon testing, PutItem return (nil, err) on ConditionalCheckFailedException
Example is not provided (but can be upon request) as inspection of the latest source code shows:
https://github.com/aws/aws-sdk-go-v2/blob/service/dynamodb/v1.20.0/service/dynamodb/api_op_PutItem.go#L34
result, metadata, err := c.invokeOperation(ctx, "PutItem", params, optFns, c.addOperationPutItemMiddlewares)
if err != nil {
return nil, err
}
Namley on ALL errors nil is returned.
Expected Behavior
PutItem to return the Item upon a ConditionalCheckFailedException
Current Behavior
PutItem returns nil upon a ConditionalCheckFailedException
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
SDK Version/Language: github.com/aws/aws-sdk-go-v2/service/dynamodb v1.20.0
Compiler and Version used
go version go1.19.6 darwin/arm64
Operating System and version
Mac OS
The text was updated successfully, but these errors were encountered: