Followup to I0e5ac1288c0d0423fa3a7a4e63173675b78aae79

add code comment on why using response.text is a bad idea here.

Change-Id: I15188a4424e7bbaed47bddc4df07adc7c14913f0
This commit is contained in:
Pavlo Shchelokovskyy 2024-09-12 16:39:11 +03:00 committed by Stephen Finucane
parent 2692290776
commit 8c8b396742

View File

@ -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: