7 ms·
> error messages which make sense to developers & end users. Giving this sort of detail direct to users is generally a bad idea for two reasons: 1. It can sca
by dspillett 13y ago
> error messages which make sense to developers & end users.
Giving this sort of detail direct to users is generally a bad idea for two reasons:
1. It can scare the living bejesus out of some of them.
2. You are handing out knowledge of your applications inner workings. If you have an unfound injection route a malicious entity might be able to use of your error messages to either find the injection flaw and/or find things to do with it once found.
This sort of detail should be logged of course, but give the users a simple code to report to you when reporting the problem ("please quote issue XY0009 when contacting support about this issue") and record the detail against that for your reference.
- sspiff 13y agoDepends on who you're targeting (developers know how to make sense of types etc) and how well you translate the error info to human-readable error messages. More information should allow you to produce better reporting. It's also not necessary to present all the information to your users, you can also make better error logs that users can send to the developers.
- dspillett 13y ago> Depends on who you're targeting (developers By all means have a developers mode which does hand out the information more readily (though I tend to be wary of that in case it gets left on in production, and because it is an extra code path that needs to be properly tested), or report the detail directly if it is an internal tool. But the post I was referring to infored (to my mind) handing the detail out to end users (and by "end users" I mean the untrustworthy mob that is the general public). > It's also not necessary to present all the information to your users, you can also make better error logs that users can send to the developers. Hence my last para, where I suggest giving the user reference to the detail without giving them the actual details (the code to give to you for looking up the stored exception report). Giving all the info to the user as an encrypted package would work too (in that case "please quote this code in any issue reports" becomes "please copy+paste this block of text into any problem report").
- einhverfr 13y agoOne option is to log everything but display something simple to the user.
- gaius 13y agoSure, but it's got to be better than the error you get from JDBC, which will be 200 lines long and not bother to include the SQL being executed, nor the username nor the database, making it utterly useless to anyone.
- dspillett 13y agoI'm not questioning the feature as a diagnostics tool, but the post I replied to seemed to be suggesting giving the error details out fairly directly to the user which is not good security practise (IMO). That 200 line JDBC error should not be going out to the end-user at all either, especially not if it did include the SQL being executed or worse still the db/authentication details (db name, user name).
- masklinn 13y ago> the post I replied to seemed to be suggesting giving the error details out fairly directly to the user I can't fathom how you'd come to such a conclusion from: > translate error information back into your application domain and generate logging and error messages which make sense to developers & end users. which describes more or less the opposite of "giving the error details out fairly directly".
- masklinn 13y agoI think you missed the whole point, which is to not give these details directly to the user: if you were a crazy pervert you could already do that by sending them Postgres's generated error messages. By having error details in a programmatic format, you can now generates messages which are actually useful and sensible to developers and/or end users if you wish to. Something which you could not do before.
- dspillett 13y agoI'm not questioning the enhancement generally: it sounds invaluable for diagnostic purposes for developers (and potentially 3rd line support), far easier than manually plucking details out of an arbitrary error string (or not getting any specific information at all). Using the information to give a user more indication of whether they should try again or report the issue and wait would be useful and safe, but if you are trying to report to the user "that code already exists, they must be unique" or "name missing, it must be provided" then you have failed input validation as that sort of thing should be picked up on much earlier in a request lifecycle IMO. I'm surprised how often I still see a full exception report echoed all the way from the data layer of an application up to my browser.
- joevandyk 13y agoYou can't catch all errors in the application server. Data in transactions that haven't committed yet isn't available (usually) to the application servers.
- masklinn 13y ago> if you are trying to report to the user "that code already exists, they must be unique" or "name missing, it must be provided" then you have failed input validation as that sort of thing should be picked up on much earlier in a request lifecycle IMO. 1. Not necessarily, most applications could use a well-designed schema to let the database do these validations and send improved results back to the user, it avoids duplicating (or triplicating) validation information. Especially for things like UNIQUE constraints, you're going to hit the database in-application when the DB will do it anyway? Unless it skips a significant amount of application work it's a complete waste of developer time (and likely application time as well). 2. A good schema can do significantly more complex, interesting and expensive (especially in-application if they need database data) validations than a mere NOT NULL check. 3. In-transaction issues can't be caught by the application server, they'll only blow up in the database. > I'm surprised how often I still see a full exception report echoed all the way from the data layer of an application up to my browser. Thus confirming that you're completely missing the point. Again, if one wanted to send database error messages to the end user one could already easily do so.