Description
Describe the bug
The dynamodb documentation specifically says that attribute names are case sensitive: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html
However, in field_cache.go the field names are being "EqualFolded" which is essentially treating them as case-insensitive.
This results in failures to parse if the field types don't match, or worse, silent decoding of data into the wrong field if the types do match.
Expected Behavior
I expected the library to conform to the dynamo spec by treating attribute names as case-sensitive.
Current Behavior
The library treats attribute names as case insensitive.
Reproduction Steps
- Create a struct with
dynamodbav
tags on two fields with names that differ only by case. e.g:
type Example struct {
Something string `dynamodbav:"a"`
SomethingElse string `dynamodbav:"A"`
}
- Write an item to the table via this struct with the fields populated with different values.
- Read the item back from the table into the struct and observe that there is a chance (depending on order of processing) that the item was incorrectly parsed into the wrong fields.
Possible Solution
Commenting out the strings.EqualFold
codepath seems to fix everything for me. Obviously that is a breaking change for anyone relying on this behaviour (though it's very shaky ground to rely on it).
AWS Go SDK V2 Module Versions Used
aws-sdk-go-v2/feature/dynamodb/[email protected]
Compiler and Version used
go version go1.21.4 darwin/arm64
Operating System and version
MacOS Sonoma 14.1.1
Activity