diff options
author | melanie witt <melwittt@gmail.com> | 2020-08-11 21:19:01 +0000 |
---|---|---|
committer | melanie witt <melwittt@gmail.com> | 2020-08-11 21:37:24 +0000 |
commit | 7d6c71ba26694c21110280e741b9ffe2d36a94ca (patch) | |
tree | 3a341ad9ac4503d135f8598232a3d303f3189e1e | |
parent | 06ab946af5aaadf3bf9885055c54caede6fa56c1 (diff) | |
download | keystone-7d6c71ba26694c21110280e741b9ffe2d36a94ca.tar.gz |
Support format for msgpack < 1.0 in token formatter
msgpack v1.0 changed its data format [1] and during a rolling upgrade, attempts
to unpack cached tokens with old data format with the new default raw=False
result in the following error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x87 in
position 3: invalid start byte
This passes raw=True to support backward-compat with the old format
until we are guaranteed to have msgpack >= 1.0 in the N-1 release of
a rolling upgrade.
Closes-Bug: #1891244
[1]
https://github.com/msgpack/msgpack-python/blob/v1.0.0/README.md#major-breaking-changes-in-msgpack-10
Change-Id: I6c61df6c097fef698c659c79402c4381ec7f3586
-rw-r--r-- | keystone/token/token_formatters.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/keystone/token/token_formatters.py b/keystone/token/token_formatters.py index f25a7a591..c251ac6d5 100644 --- a/keystone/token/token_formatters.py +++ b/keystone/token/token_formatters.py @@ -170,7 +170,15 @@ class TokenFormatter(object): """ serialized_payload = self.unpack(token) - versioned_payload = msgpack.unpackb(serialized_payload) + # TODO(melwitt): msgpack changed their data format in version 1.0, so + # in order to support a rolling upgrade, we must pass raw=True to + # to support the old format. The try-except may be removed in the once + # the N-1 release no longer supports msgpack < 1.0. + try: + versioned_payload = msgpack.unpackb(serialized_payload) + except UnicodeDecodeError: + versioned_payload = msgpack.unpackb(serialized_payload, raw=True) + version, payload = versioned_payload[0], versioned_payload[1:] for payload_class in _PAYLOAD_CLASSES: |