Blob Blame History Raw
From 6a5a335f82ed0f2f5a4a0a6905e45cb7bcb84350 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <dvlasenk@redhat.com>
Date: Tue, 26 Mar 2013 11:32:59 +0100
Subject: [LIBREPORT PATCH 1/5] reporter-rhtsupport: fix hint query to use
 correct URL

We should use rs/problems, not rs/cases/NNNNNNNN/problems.

To make similar bugs easier to spot in the future,
I added error message if we did get an error.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Signed-off-by: Martin Milata <mmilata@redhat.com>
---
 src/plugins/reporter-rhtsupport.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
index fe13423..2eb41b4 100644
--- a/src/plugins/reporter-rhtsupport.c
+++ b/src/plugins/reporter-rhtsupport.c
@@ -261,6 +261,8 @@ int main(int argc, char **argv)
     );
     free_map_string(settings);
 
+    char *base_api_url = xstrdup(url);
+
     if (opts & OPT_t)
     {
         if (!case_no)
@@ -386,7 +388,7 @@ int main(int argc, char **argv)
     {
         /* Check for hints and show them if we have something */
         log(_("Checking for hints"));
-        result = get_rhts_hints(url,
+        result = get_rhts_hints(base_api_url,
                 login,
                 password,
                 ssl_verify,
@@ -409,6 +411,16 @@ int main(int argc, char **argv)
         "</problems>"
         );
 #endif
+        if (result->error)
+        {
+            /* We don't use result->msg here because it looks like this:
+             *  Error in file upload at 'URL', HTTP code: 404,
+             *  server says: '<?xml...?><error...><code>404</code><message>...</message></error>'
+             * TODO: make server send bare textual msgs, not XML.
+             */
+            error_msg("Error in file upload at '%s', HTTP code: %d",
+                    base_api_url, result->http_resp_code);
+        }
         if (result->error == 0 && result->body)
         {
             /* The message might contain URLs to known solutions and such */
@@ -559,6 +571,7 @@ int main(int argc, char **argv)
     free_rhts_result(result_atch);
     free_rhts_result(result);
 
+    free(base_api_url);
     free(url);
     free(login);
     free(password);
-- 
1.8.1.4