Skip to content

DynamoDB Enhanced Client - QueryConditional does not support reserved characters : and # #1806

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

Closed
dhegberg opened this issue May 1, 2020 · 1 comment · Fixed by #1807
Closed
Labels
bug This issue is a bug. dynamodb-enhanced

Comments

@dhegberg
Copy link

dhegberg commented May 1, 2020

Describe the bug

The reserved characters : and # are not "scrubbed" from expression key/value mappers when the QueryConditional calls cleanAttributeName

Example QueryConditional:

private static final UnaryOperator<String> EXPRESSION_KEY_MAPPER =
k -> "#AMZN_MAPPED_" + cleanAttributeName(k);

cleanAttributeName:

public static String cleanAttributeName(String key) {
boolean somethingChanged = false;
char[] chars = key.toCharArray();
for (int i = 0; i < chars.length; ++i) {
if (chars[i] == '*' || chars[i] == '.' || chars[i] == '-') {
chars[i] = '_';
somethingChanged = true;
}
}
return somethingChanged ? new String(chars) : key;
}

Expected Behavior

Attribute names with : and # characters would be replaced with placeholders, allowing for successful query of table with those attribute names.

Current Behavior

The reserved characters are not replaced, resulting in a 400 due to "ExpressionAttributeNames contains invalid key" during query request.

@dhegberg dhegberg added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 1, 2020
@bmaizels
Copy link
Contributor

bmaizels commented May 1, 2020

Thanks for the bug report. Working on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. dynamodb-enhanced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants