Skip to content
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

Unicode characters cause dynamodb get-item to fail #853

Closed
sbressler opened this issue Jul 25, 2014 · 6 comments
Closed

Unicode characters cause dynamodb get-item to fail #853

sbressler opened this issue Jul 25, 2014 · 6 comments
Labels
bug This issue is a bug. unicode

Comments

@sbressler
Copy link

Reported on this resolved issue, so opening a new issue.

I'm having the same issue when querying dynamodb for an attribute of an item which has non-ASCII characters:

% aws dynamodb query --table-name <table> --select "<key>" --attributes-to-get <attribute> --debug
...
2014-07-25 13:20:37,038 - awscli.errorhandler - DEBUG - HTTP Response Code: 400
2014-07-25 13:20:37,038 - awscli.clidriver - DEBUG - Exception caught in main()
...
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 1304: ordinal not in range(128)
2014-07-25 13:20:37,041 - awscli.clidriver - DEBUG - Exiting with rc 255

'ascii' codec can't encode character u'\u2026' in position 1304: ordinal not in range(128)

aws --version: aws-cli/1.3.4 Python/2.7.6 Linux/2.6.18-164.el5

I've also seen it fail on u'\xbb'. I imagine it would fail on any non-ASCII character.

@jamesls
Copy link
Member

jamesls commented Jul 28, 2014

Can you clarify if in your command <attribute> is type on the command line or if it comes from a JSON file?

In both cases, the encoding used will be based on your LANG/LC_ALL settings. If the JSON file is encoded in utf-8, try setting LANG="en_US.UTF-8" in your shell.

If this doesn't work, can you post the output of running the locale command?

@sbressler
Copy link
Author

<attribute> was typed on command line in the above command.
Typing locale includes what you seemed to hope for in the output already on the machine I ran aws CLI on: LANG=en_US.UTF-8

@sbressler
Copy link
Author

Turns out my “--key” argument wasn’t following the documentation on how it was supposed to be specified. I was using:
--key "http://www.<website>.com/"
I should have been using:
--key '{"url": {"S":"http://www.<website>.com"}}'

Do you know why without the more complex syntax I got the error I did? Can the error message be improved?

@jamesls
Copy link
Member

jamesls commented Jul 29, 2014

Which argument are you talking about? There's a --key-conditions argument, but it doesn't match the syntax you've provided.

Just want to see if I can repro the issue so I can understand why it's raising that exception.

@jamesls
Copy link
Member

jamesls commented Aug 8, 2014

Closing due to inactivity, will reopen if more info is provided.

@jamesls jamesls closed this as completed Aug 8, 2014
@sbressler
Copy link
Author

I switched from query to get-item since I realized that was more what I wanted, so I was using the --key argument:
aws dynamodb get-item --table-name <table> --key '{"<index>": {"S":"<value>"}}' --attributes-to-get <attribute>

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. unicode
Projects
None yet
Development

No branches or pull requests

4 participants