From 9b683b2ed823e879bf2345cb62204277b1af87dc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 10 Jan 2019 15:33:52 +0100 Subject: improve logging for reoccurrances of #5492 --- src/backend/taler-merchant-httpd_proposal.c | 37 ++++++++++++++++++++++------- src/lib/testing_api_cmd_pay.c | 8 +++++-- 2 files changed, 35 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c index 0ae6dbe8..5a63afde 100644 --- a/src/backend/taler-merchant-httpd_proposal.c +++ b/src/backend/taler-merchant-httpd_proposal.c @@ -474,24 +474,45 @@ proposal_put (struct MHD_Connection *connection, } { /* Hard error could be constraint violation, check if order already exists */ - json_t *dummy_contract_terms = NULL; + json_t *contract_terms = NULL; qs = db->find_order (db->cls, - &dummy_contract_terms, + &contract_terms, order_id, &mi->pubkey); - if (NULL != dummy_contract_terms) - json_decref (dummy_contract_terms); if (0 < qs) { /* Yep, indeed uniqueness constraint violation */ + int rv; + char *msg; + GNUNET_JSON_parse_free (spec); - return TMH_RESPONSE_reply_external_error (connection, - TALER_EC_PROPOSAL_STORE_DB_ERROR_ALREADY_EXISTS, - "proposal already exists"); + GNUNET_asprintf (&msg, + "order ID `%s' already exists", + order_id); + { + /* Log plenty of details for the admin */ + char *js; + + js = json_dumps (contract_terms, + JSON_COMPACT); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Order ID `%s' already exists with proposal `%s'\n"), + order_id, + js); + free (js); + } + json_decref (contract_terms); + + /* contract_terms may be private, only expose duplicate order_id to the network */ + rv = TMH_RESPONSE_reply_external_error (connection, + TALER_EC_PROPOSAL_STORE_DB_ERROR_ALREADY_EXISTS, + msg); + GNUNET_free (msg); + return rv; } } - /* Other hard transaction error */ + /* Other hard transaction error (disk full, etc.) */ GNUNET_JSON_parse_free (spec); return TMH_RESPONSE_reply_internal_error (connection, TALER_EC_PROPOSAL_STORE_DB_ERROR_HARD, diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c index 6121171e..15e0adac 100644 --- a/src/lib/testing_api_cmd_pay.c +++ b/src/lib/testing_api_cmd_pay.c @@ -802,12 +802,16 @@ _pay_run (const char *merchant_url, &error_name, &error_line)) { + char *js; + + js = json_dumps (contract_terms, + JSON_INDENT (1)); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Parser failed on %s:%u for input `%s'\n", error_name, error_line, - json_dumps (contract_terms, - JSON_INDENT (1))); + js); + free (js); GNUNET_break_op (0); return NULL; } -- cgit v1.2.3