Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Console/log output for malformed XML requests is not very helpful

#2481

Hey guys,

First time patcher here, so go easy on me. I'm writing a REST service in Rails and a client in Flex. I knew my Flex app was sending malformed data but I had no way of inspecting it. The Rails log output really wasn't very helpful:


/!\ FAILSAFE /!\  Fri Apr 10 19:44:12 -0700 2009
  Status: 500 Internal Server Error
  You have a nil object when you didn't expect it!
The error occurred while evaluating nil.name

So my patch simply echo's the actual raw request and provides much more information:


It seems there was an error parsing the request.
The raw request is provided below:

some-malformed-XML-string-here

/!\ FAILSAFE /!\  Fri Apr 10 19:44:12 -0700 2009
  Status: 500 Internal Server Error
  You have a nil object when you didn't expect it!
The error occurred while evaluating nil.name

My patch uses puts (is that okay?)

Reported by Chris Bielinski · April 11th, 2009 @ 04:06 AM

State: committed
Milestone: 2.3.4
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from debug, feature, patch, request, xml to bugmash, debug, feature, patch, request, xml

    August 6th, 2009 @ 01:40 PM

  2. Gabe da Silveira
    Gabe da Silveira

    +1 on fixing this issue. I've been annoyed by this for quite some time. Using puts is not the right approach, but we ought to be able to do something about it...

    August 9th, 2009 @ 12:21 PM

  3. Elad Meidar
    Elad Meidar

    +1 Verified... /!\ so annoying /!\

    Patch applies and all tests pass on 2-3-stable (it's more of an output formatting thing... needs tests?)

    Attached a patch for master.

    August 9th, 2009 @ 09:12 PM

  4. Rizwan Reza
    Rizwan Reza

    +1 On the feature. But I would suggest adding some tests.

    August 10th, 2009 @ 02:58 AM

  5. Jeremy Kemper
    Jeremy Kemper
    • Assigned user set to Jeremy Kemper
    • State changed from new to incomplete
    • Milestone changed from 2.x to 2.3.4

    Needs tests.

    August 10th, 2009 @ 06:50 AM

  6. John Pignata
    John Pignata

    Here's my shot at it.

    1) Instead of using puts, I've used the Rails.logger or $stderr in the absence of that.
    2) I've added tests to the json and xml parser tests which capture $stderr and ensure that the log entry was made

    Let me know your feedback.

    August 11th, 2009 @ 06:04 AM

  7. Rizwan Reza
    Rizwan Reza

    Verified. The patch by John applies cleanly on master. It doesn't work in 2-3-stable.

    August 13th, 2009 @ 07:05 AM

  8. John Pignata
    John Pignata

    Thanks, Rizwan. Here's a patch that applies to 2-3-stable.

    August 13th, 2009 @ 02:48 PM

  9. Elad Meidar
    Elad Meidar

    2-3-stable patch applies cleanly, tests pass. Tested manually as well.

    August 13th, 2009 @ 09:54 PM

  10. Repository
    Repository
    • State changed from incomplete to committed

    (from [1cf32ad35a32cc1259a5aebfb894f53610ffac8e]) Adding a call to logger from params_parser to give detailed debug information when invalid xml or json is posted

    [#2481 Console/log output for malformed XML requests is not very helpful state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/1cf32ad35a32cc1259a5aebfb894f5...

    August 16th, 2009 @ 12:51 AM

  11. Repository
    Repository

    (from [679128da58636f3ec96e24fcb7daac24666b2dad]) Adding a call to logger from params_parser to give detailed debug information when invalid xml or json is posted

    [#2481 Console/log output for malformed XML requests is not very helpful state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/679128da58636f3ec96e24fcb7daac...

    August 16th, 2009 @ 12:51 AM