Bug 670492 - ABRT is consuming non-standard header
Summary: ABRT is consuming non-standard header
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: abrt
Version: 6.1
Hardware: Unspecified
OS: Unspecified
urgent
medium
Target Milestone: rc
: ---
Assignee: Denys Vlasenko
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-01-18 13:33 UTC by Andrew Hecox
Modified: 2011-05-19 13:41 UTC (History)
11 users (show)

Fixed In Version: abrt-1.1.16-1.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-05-19 13:41:41 UTC
Target Upstream Version:


Attachments (Terms of Use)
Proposed patch (1.47 KB, patch)
2011-02-03 14:21 UTC, Denys Vlasenko
no flags Details | Diff
Patch to add "Accept: text/plain" header (1.36 KB, patch)
2011-02-04 14:31 UTC, Denys Vlasenko
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0619 0 normal SHIPPED_LIVE abrt bug fix update 2011-05-18 17:56:11 UTC

Description Andrew Hecox 2011-01-18 13:33:25 UTC
When looking for responses, ABRT appears to be looking at the undocument Strata-* headers, which were used in early development and are now left in only to support the 6.0 bits. We see this when we send back a message with a request (eg, a 403): if the Strata headers are empty, no message is displayed to clients.

ABRT should look at the message payload, not Strata-* headers, for what message to display to a user.

Comment 2 Denys Vlasenko 2011-01-25 14:07:14 UTC
Currently abrt uses "Strata-Message:" header in hopes to extract more useful error description:

    abrt_post_string(case_state, case_url.c_str(), "application/xml", case_data);
    char *case_location = find_header_in_abrt_post_state(case_state, "Location:");
    switch (case_state->http_resp_code)
    {
    case 301: /* "301 Moved Permanently" */
    case 302: /* "302 Found" (just in case) */
    case 305: /* "305 Use Proxy" */
        ...redirect code here...
    default:
        errmsg = case_state->curl_error_msg;
        if (errmsg)
            retval = xasprintf("error in case creation: %s", errmsg);
        else
        {
            errmsg = find_header_in_abrt_post_state(case_state, "Strata-Message:");
            if ((!errmsg || !errmsg[0]) && case_state->body && case_state->body[0])
                errmsg = case_state->body;
            if (errmsg)
                retval = xasprintf("error in case creation, HTTP code: %d, server says: '%s'",
                        case_state->http_resp_code, errmsg);
            else
                retval = xasprintf("error in case creation, HTTP code: %d",
                        case_state->http_resp_code);
        }
        break;

In the above code, default: branch is entered only when an error has happened. If "Strata-Message:" header is not found, then response body will be used.

IOW, if server stops emitting "Strata-Message:" headers, the code will still work.

It is certainly possible, and easy, to just remove find_header_in_abrt_post_state(case_state, "Strata-Message:") code.

Andrew, are there other header field(s) we should examine instead for human-readable error messages?

Comment 3 Andrew Hecox 2011-01-26 16:00:23 UTC
if you're reading the response, you should be set. When we've tested RHEL 6.0 bits, they don't seem to be doing that. 

Has the code changed since 6.0? If not, maybe we should turn off the headers somewhere to help you debug?

-Ah

Comment 4 Denys Vlasenko 2011-01-31 14:03:01 UTC
(In reply to comment #3)
> if you're reading the response, you should be set. When we've tested RHEL 6.0
> bits, they don't seem to be doing that.

I believe we do use server's response. In detail, current code looks for the error message as follows:

1. if curl library provided error message (retrieved using check_curl_error() after curl_easy_perform() and saved in case_state->curl_error_msg), use it

2. if not, use MSG from "Strata-Message: MSG" if available

3. if not, use HTTP body of the error reply from server, if available

4. if not, just display numeric HTTP error code (or -1 if there were no reply from server at all (although usually in this case there will be curl error message and we'd be in 1st case))


(I have a bit of concern with (3). HTTP body usually contains useful error diagnostics, but it may contains far too much fancy HTML which clutters the message. But OTOH, it's better that just giving only HTTP error code...)

Comment 5 Andrew Hecox 2011-01-31 22:41:18 UTC
we should drop #2, since it's not in the spec at all.

re: #3, if we're getting an unhelpful error, it's a bug in the server which we should fix, and can on a much shorter update cycle. I agree that the defaults often aren't very helpful.

The rest of the logic seems good. That said, I still don't think #3 is working, but maybe that's because in our tests we removed the content from the Strata message rather than remove the header entirely. We'll test that...

Comment 6 Denys Vlasenko 2011-02-03 14:21:36 UTC
Created attachment 476794 [details]
Proposed patch

This patch removes code which looks into Strata-Message: header

Comment 7 Denys Vlasenko 2011-02-03 14:56:52 UTC
Applied to git and tested.

Comment 8 Denys Vlasenko 2011-02-03 15:03:00 UTC
(In reply to comment #4)
> I believe we do use server's response. In detail, current code looks for the
> error message as follows:
> 
...
> 3. if not, use HTTP body of the error reply from server, if available
> 
> 4. if not, just display numeric HTTP error code (or -1 if there were no reply
> from server at all (although usually in this case there will be curl error
> message and we'd be in 1st case))
> 
> 
> I have a bit of concern with (3). HTTP body usually contains useful error
> diagnostics, but it may contains far too much fancy HTML which clutters the
> message. But OTOH, it's better that just giving only HTTP error code...

Just a note about how this looks from the user's POV:

For example, in today's testing I gave wrong username, and user sees the following error in abrt gui:

error in case creation, HTTP code: 401, server says: '401 Unauthorized

This request requires authentication..<skip>..'

See the problem? The HTTP body we see here is meant for the browser. Thank God in this case it only contained a few line breaks. But in other cases it can easily look like this:

error in case creation, HTTP code: 401, server says: '<h1>401 Unauthorized</h1>

This request <font color=red>requires</font> authentication....'


Not nice, eh?

Comment 9 Chris Bredesen 2011-02-03 15:05:34 UTC
Comment 8 is exactly why we should not be relying on the returned text and instead implementing the HTTP protocol which has exactly enough information to give a reasonable, localized response to the user based on the HTTP 401.

Comment 10 Brian 2011-02-03 15:14:18 UTC
Thanks Denys, I'll see if I can help this along after sprint meetings today.

Comment 11 Brian 2011-02-03 19:23:22 UTC
It seems to me that the ideal solution (unless we adopt the policy from Comment 9) is to ensure that clients specify their "Accept" parameter. If ABRT accepts "text/plain", then the API should be fulfilling the contract by sending back HTML free text. If the API isn't, I'll fix that. Is an "Accept" parameter already being sent by ABRT? Can it be sent easily?

Comment 12 Andrew Hecox 2011-02-04 13:23:24 UTC
some thoughts:

 - if the problem is you're running out of UI space, then I agree with comment #9 that you should just interrupt the response code and display your own message.

 - if you just want a different format, then I agree with comment #11, use Accept: to ask for it and we'll make sure we support it.

Comment 13 Andrew Hecox 2011-02-04 13:23:58 UTC
s/interrupt/interpret/

Comment 14 Denys Vlasenko 2011-02-04 13:57:23 UTC
(In reply to comment #12)
> some thoughts:
> 
>  - if the problem is you're running out of UI space, then I agree with comment
> #9 that you should just interrupt the response code and display your own
> message.
> 
>  - if you just want a different format, then I agree with comment #11, use
> Accept: to ask for it and we'll make sure we support it.

We need a plain text, preferably one line error messages which are suitable for displaying on dumb terminals, storing in logs/databases, and such.

I will experiment with adding "Accept: text/plain" header. Thanks for the idea.

Comment 15 Denys Vlasenko 2011-02-04 14:31:31 UTC
Created attachment 477026 [details]
Patch to add "Accept: text/plain" header

Patch is in abrt git now.
Run tested against both Bugzilla and RHTS.

Comment 17 Andrew Hecox 2011-02-06 11:47:21 UTC
Denys,

the server won't guarantee a one-line error message: if that's your constraint, it'd be better to process the response code, not display it directly.

Comment 18 Denys Vlasenko 2011-02-07 12:18:14 UTC
(In reply to comment #17)
> the server won't guarantee a one-line error message: if that's your constraint,
> it'd be better to process the response code, not display it directly.

I didn't mean "one-line" as "it should fit into 80 chars".

I meant that it should be just a string without any fancy formatting: no HTML, no XML, not even line breaks ostensibly to make it look better on the text console.

But it's ok if the message is long. An example of such error message:

"Reporting disabled because the backtrace is unusable. Please try to install debuginfo manually using the command: 'debuginfo-install PACKAGE_NAME', then use the Refresh button to regenerate the backtrace."

Comment 19 Andrew Hecox 2011-02-13 01:06:43 UTC
OK, cool, thanks. We'll make sure text/plain works on the server.

Comment 26 errata-xmlrpc 2011-05-19 13:41:41 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0619.html


Note You need to log in before you can comment on or make changes to this bug.