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

None ascii characters cause alias function exception? #1737

Closed
eagleliang opened this issue Nov 3, 2016 · 5 comments
Closed

None ascii characters cause alias function exception? #1737

eagleliang opened this issue Nov 3, 2016 · 5 comments
Labels

Comments

@eagleliang
Copy link

If use Chinese characters as alias of matrix, it will cause following error:
Graphite encountered an unexpected error while handling your request.

Please contact your site administrator if the problem persists.

Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/opt/graphite/webapp/graphite/render/views.py", line 71, in renderView
requestKey = hashRequest(request)
File "/opt/graphite/webapp/graphite/render/hashing.py", line 33, in hashRequest
return compactHash(normalizedParams)
File "/opt/graphite/webapp/graphite/render/hashing.py", line 46, in compactHash
hash.update(string)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 178-179: ordinal not in range(128)

@eagleliang eagleliang changed the title alias function only support ascii characters None ascii characters cause alias function exception? Nov 11, 2016
@eagleliang eagleliang changed the title None ascii characters cause alias function exception? None asiic characters cause alias function exception? Nov 11, 2016
@eagleliang eagleliang changed the title None asiic characters cause alias function exception? None ascii characters cause alias function exception? Nov 11, 2016
@pfctgeorge
Copy link

@eagleliang

you can simply do these 2 things to resolve:

  1. import smart_str
from django.utils.encoding import smart_str
  1. edit this line from hash.update(string) to hash.update(smart_str(string))

@deniszh deniszh added the bug label Mar 20, 2017
ecsv added a commit to FreifunkVogtland/ffv-grafana-config that referenced this issue Sep 12, 2017
graphite-web cannot use Unicode characters in aliases [1] in the moment.
The grafana json dashboard generator must therefore remove these characters
to avoid rendering errors when a Freifunk node name uses umlauts.

[1] graphite-project/graphite-web#1737
@eagleliang
Copy link
Author

@deniszh the change mentioned by @pfctgeorge is OK to pull request?

@DanCech
Copy link
Member

DanCech commented Feb 14, 2018

This is quite out of date now since the updates to add python 3.x support.

@deniszh
Copy link
Member

deniszh commented Feb 14, 2018

smart_str() will work both, for python3 and python2. It's built in and should be safe to use. But I'm not sure how it will be compatible with carbon and 3rd party tools.
@eagleliang : You can create PR, it's a good thing - but we need to test it how it works with different combinations of pythons/djangos/carbons/relays etc.

@eagleliang
Copy link
Author

Yes, it's out of date. It's resolved now. Sorry about that. Just close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants