From 8c8b396742ac29dbf702d2a0f3803e7d697e61dd Mon Sep 17 00:00:00 2001 From: Pavlo Shchelokovskyy Date: Thu, 12 Sep 2024 16:39:11 +0300 Subject: [PATCH] Followup to I0e5ac1288c0d0423fa3a7a4e63173675b78aae79 add code comment on why using response.text is a bad idea here. Change-Id: I15188a4424e7bbaed47bddc4df07adc7c14913f0 --- openstack/key_manager/v1/secret.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openstack/key_manager/v1/secret.py b/openstack/key_manager/v1/secret.py index 04a530473..fc8515f7a 100644 --- a/openstack/key_manager/v1/secret.py +++ b/openstack/key_manager/v1/secret.py @@ -112,6 +112,13 @@ class Secret(resource.Resource): headers={"Accept": content_type}, skip_cache=skip_cache, ) + # NOTE(pas-ha): do not return payload.text here, + # as it will be decoded to whatever requests and chardet detected, + # and if they are wrong, there'd be no way of getting original + # bytes back and try to re-decode. + # At least this way, the encoding is always the same, + # so SDK user can always get original bytes back and fix things. + # Besides, this is exactly what python-barbicanclient does. if content_type == "text/plain": response["payload"] = payload.content.decode("UTF-8") else: