Bug 808581

Summary: Stack traces logged to production.log for user-level validation errors
Product: Red Hat Satellite Reporter: Jeff Weiss <jweiss>
Component: Content ManagementAssignee: Petr Chalupa <pchalupa>
Status: CLOSED UPSTREAM QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.0CC: dajohnso, inecas, lzap, mmccune, pchalupa, tsanders
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-19 18:12:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
katello log none

Description Jeff Weiss 2012-03-30 18:44:37 UTC
Created attachment 574072 [details]
katello log

Description of problem:
The only stacktraces that should be logged are conditions that are unexpected to the developer.  User-level errors like "I tried to create two products with the same name" do not require a stacktrace.  Logs are completely polluted with them.  See attachment.  The only "real" error in there requiring a stacktrace is the JDBC batch update error near the end.

Version-Release number of selected component (if applicable):
CloudForms System Engine Version: 0.1.307-1.el6

How reproducible:
always

Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Lukas Zapletal 2012-04-02 08:36:35 UTC
This is more Rails3 "feature" than ours. From all of the reported traces they all go to:

/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/validations.rb:49:in `save!'

When you use method with exclamation mark, you want Rails3 to report the error. Ivan is there a configuration for Rails3 that would not post backtraces?

Comment 2 Ivan Necas 2012-04-02 09:14:23 UTC
The logging of back-trace is in fact handled by Katello itself. For example for Organization creation through UI that is this code:

    # ...
    rescue Exception => error
      # ...
      Rails.logger.error error.backtrace.join("\n")

So the solution would be to update our UI controllers so that it doesn't log trace for validation errors, something like:

    # ...
    rescue Exception => error
      # ...
      Rails.logger.error error.backtrace.join("\n") unless error.is_a? ActiveRecord::RecordInvalid

Notice that API logs stack trace for this kind of error with debug level, which is acceptable/desirable, so that it doesn't pollute the production log, but it still might be helpful in development phase.

Comment 4 Petr Chalupa 2012-06-04 12:23:46 UTC
Imho there should only be:

# ...
rescue ActiveRecord::RecordInvalid
  # ... usually render some error to a user, log nothing
end

Other errors not expected by developer are rescued and logged by rescue_from(StandardError) in application controller.

Comment 5 Mike McCune 2012-08-03 17:00:25 UTC
addressed in:

https://github.com/Katello/katello/pull/176

Comment 6 Petr Chalupa 2012-10-05 06:58:38 UTC
fixed in aec316257d8fe36e1e01462fa889bfb5ad0556ab

Comment 7 Mike McCune 2013-09-19 18:12:47 UTC
These bugs have been resolved in upstream projects for a period of months so I'm mass-closing them as CLOSED:UPSTREAM.  If this is a mistake feel free to re-open.