Ema has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403664 )

Change subject: Alerts instrumentation: return instance of bytes
......................................................................

Alerts instrumentation: return instance of bytes

Twisted returns a 500 if the returned body is not an instance of
'bytes'. 'unicode' values are not. Make sure we return a value of type
'str' instead.

Bug: T184721
Ref: 
https://github.com/twisted/twisted/blob/8857cbf4ec6a88b6cfb758ccaa9161d6b2f48009/src/twisted/web/server.py#L314
Change-Id: I23aa6f24ed729487621fe61625d86600d8c25b03
---
M pybal/instrumentation.py
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/debs/pybal 
refs/changes/64/403664/1

diff --git a/pybal/instrumentation.py b/pybal/instrumentation.py
index 386b174..64437e8 100644
--- a/pybal/instrumentation.py
+++ b/pybal/instrumentation.py
@@ -90,7 +90,10 @@
         if wantJson(request):
             return json.dumps(resp)
         else:
-            return "%s - %s" % (resp['status'].upper(), resp['msg'])
+            # Twisted returns a 500 if the returned body is not an instance of
+            # 'bytes'. 'unicode' values are not. Make sure we return a 'str'
+            # instead. See https://phabricator.wikimedia.org/T184721
+            return str("%s - %s" % (resp['status'].upper(), resp['msg']))
 
 class PoolsRoot(Resource):
     """Pools base resource.

-- 
To view, visit https://gerrit.wikimedia.org/r/403664
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23aa6f24ed729487621fe61625d86600d8c25b03
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Ema <e...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to