diff --git a/testbench/error.py b/testbench/error.py index aee4c159..5afe3228 100644 --- a/testbench/error.py +++ b/testbench/error.py @@ -29,7 +29,13 @@ def __init__(self, msg, code): self.code = code def as_response(self): - return flask.make_response(flask.jsonify(self.msg), self.code) + # Include both code and message so we follow the schema outlined in + # https://cloud.google.com/apis/design/errors#error_model and some + # clients depend on code being specified, otherwise behavior is + # undefined. + return flask.make_response( + flask.jsonify(code=self.code, message=self.msg), self.code + ) @staticmethod def handler(ex):