-
Notifications
You must be signed in to change notification settings - Fork 2k
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
datastore: Prevent unicode/ascii conversion errors #2904
Conversation
@@ -123,7 +123,7 @@ def _cache_types(context): | |||
if 'nested' not in _type_names: | |||
native_json = _pg_version_is_at_least(connection, '9.2') | |||
|
|||
log.info("Create nested type. Native JSON: {0}".format( | |||
log.info(u"Create nested type. Native JSON: {0}".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure the ValidationError changes below are correct, but is it safe to pass unicode to any logger that's configured? Have you tested this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using repr() for user-supplied values sent to logs. That seems safer.
You are right, it's usually not a good idea. Do you prefer |
@mordae |
Some error messages were causing the errors due to format conversion of unicode fields into str templates. Signed-off-by: Jan Dvořák <mordae@anilinux.org>
OK, let's make it simpler. These are just the |
And this should take care of the log messages as per your instruction. Is this acceptable? |
Logging statements had a potential to crash on unicode inputs. Make sure they are always escaped. Signed-off-by: Jan Dvořák <mordae@anilinux.org>
@@ -1310,8 +1313,7 @@ def make_private(context, data_dict): | |||
|
|||
|
|||
def make_public(context, data_dict): | |||
log.info('Making resource {0} public'.format( | |||
data_dict['resource_id'])) | |||
log.info('Making resource {resource_id!r} public'.format(**data_dict)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you been using something other than UUIDs for your resource_ids?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, just being consistent and quoting all of them. It's UnicodeText
in the model...
datastore: Prevent unicode/ascii conversion errors
@amercader This puts python reprs in our logs now, do you think that's a concern for backporting? |
As for the |
Some error messages were causing the errors due to format conversion of unicode fields into str templates.