From c68fab6c3137ddfd88fbad987f119e30e2550981 Mon Sep 17 00:00:00 2001 From: Shahbaz Nazir Date: Thu, 13 Sep 2018 16:03:22 +0200 Subject: [PATCH] Problem: A duplicate tx may result in HTTP 500. * Improve parsing of errors received from Tendermint RPC. --- bigchaindb/lib.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bigchaindb/lib.py b/bigchaindb/lib.py index f6761aa6..2dadcb90 100644 --- a/bigchaindb/lib.py +++ b/bigchaindb/lib.py @@ -100,7 +100,14 @@ class BigchainDB(object): error = response.get('error') if error: - return (500, error) + status_code = 500 + message = error.get('message', 'Internal Error') + data = error.get('data', '') + + if 'Tx already exists in cache' in data: + status_code = 400 + + return (status_code, message + ' - ' + data) result = response['result'] if mode == self.mode_commit: