"Humanized failures" should still have a traceback, hidden by default #971

Open
opened 2010-02-25 02:47:27 +00:00 by davidsarah · 4 comments
davidsarah commented 2010-02-25 02:47:27 +00:00
Owner

Currently, failures that occur in a WUI operation (that is, a webapi operation with HTML output) go through [humanize_failure]source:src/allmydata/web/common.py#L149 in web/common.py, in order to produce a more informative error message. This is better in most cases than dumping an exception traceback, but sometimes you really do also want the traceback for debugging.

DHTML could be used to hide the traceback by default, like this:

<!doctype html>
<html>
  <head>
    <script type="text/javascript">
      function toggleDebug() {
        var el = document.getElementById('debug');
        show = el.style.display === 'none';
        el.style.display = show ? '' : 'none';
        document.getElementById('toggle').innerHTML =
          show ? 'Hide debugging information' : 'Show debugging information';
      }
      window.onload = toggleDebug;
    </script>
  </head>
<body>
  <p>
  <a id="toggle" onclick="toggleDebug();"
     style="text-decoration: none; border-bottom: 1px dashed #000000"></a>
  </p>
  <div id="debug"><p>Traceback</p></div>
</body>
</html>

A traceback can be obtained from a twisted.python.failure.Failure object using:

  from StringIO import StringIO
  sfile = StringIO()
  f.printTraceback(sfile)  # or printDetailedTraceback
  sfile.flush()
  ... sfile.getvalue() ...
Currently, failures that occur in a WUI operation (that is, a webapi operation with HTML output) go through [humanize_failure]source:src/allmydata/web/common.py#L149 in `web/common.py`, in order to produce a more informative error message. This is better in most cases than dumping an exception traceback, but sometimes you really do *also* want the traceback for debugging. DHTML could be used to hide the traceback by default, like this: ``` <!doctype html> <html> <head> <script type="text/javascript"> function toggleDebug() { var el = document.getElementById('debug'); show = el.style.display === 'none'; el.style.display = show ? '' : 'none'; document.getElementById('toggle').innerHTML = show ? 'Hide debugging information' : 'Show debugging information'; } window.onload = toggleDebug; </script> </head> <body> <p> <a id="toggle" onclick="toggleDebug();" style="text-decoration: none; border-bottom: 1px dashed #000000"></a> </p> <div id="debug"><p>Traceback</p></div> </body> </html> ``` A traceback can be obtained from a `twisted.python.failure.Failure` object using: ``` from StringIO import StringIO sfile = StringIO() f.printTraceback(sfile) # or printDetailedTraceback sfile.flush() ... sfile.getvalue() ... ```
tahoe-lafs added the
code-frontend-web
major
enhancement
1.6.0
labels 2010-02-25 02:47:27 +00:00
tahoe-lafs added this to the 1.7.0 milestone 2010-02-25 02:47:27 +00:00
davidsarah commented 2010-02-25 02:51:19 +00:00
Author
Owner

The [humanize_failure link]source:src/allmydata/web/common.py#L149 was supposed to be to web/common.py.

The [humanize_failure link]source:src/allmydata/web/common.py#L149 was supposed to be to `web/common.py`.
kpreid commented 2010-02-25 03:58:33 +00:00
Author
Owner

innerHTML is currently non-standardized and has somewhat hairy semantics. Use DOM node manipulation instead, or put the two texts for the button in spans and toggle their visibility too.

var toggle = document.getElementById('toggle');
var node; while (node = toggle.firstChild) { toggle.removeChild(node); }
toggle.appendChild(document.createTextNode(show ? 'Hide debugging information' : 'Show debugging information'));
`innerHTML` is currently non-standardized and has somewhat hairy semantics. Use DOM node manipulation instead, or put the two texts for the button in spans and toggle their visibility too. ``` var toggle = document.getElementById('toggle'); var node; while (node = toggle.firstChild) { toggle.removeChild(node); } toggle.appendChild(document.createTextNode(show ? 'Hide debugging information' : 'Show debugging information')); ```
davidsarah commented 2010-02-25 04:47:39 +00:00
Author
Owner

Thanks, I was wondering how to do that without using innerHTML.

Thanks, I was wondering how to do that without using `innerHTML`.
davidsarah commented 2010-03-29 00:44:37 +00:00
Author
Owner

This ticket and #1008 are somewhat contradictory. See my argument in ticket:1008#comment:-1 for why the information revealed by a traceback doesn't in practice tend to lead to confidentiality or privacy breaches.

This ticket and #1008 are somewhat contradictory. See my argument in ticket:1008#[comment:-1](/tahoe-lafs/trac-2024-07-25/issues/971#issuecomment--1) for why the information revealed by a traceback doesn't in practice tend to lead to confidentiality or privacy breaches.
tahoe-lafs modified the milestone from 1.7.0 to soon 2010-05-30 21:36:03 +00:00
tahoe-lafs modified the milestone from soon to 1.7.1 2010-06-12 21:11:40 +00:00
tahoe-lafs modified the milestone from 1.7.1 to 1.8.0 2010-07-17 04:20:52 +00:00
tahoe-lafs modified the milestone from 1.8.0 to soon 2010-08-08 05:35:01 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tahoe-lafs/trac-2024-07-25#971
No description provided.