Merge lp:~wallyworld/launchpad/codehost-error-trackback-leak into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Ian Booth |
Approved revision: | no longer in the source branch. |
Merged at revision: | 12079 |
Proposed branch: | lp:~wallyworld/launchpad/codehost-error-trackback-leak |
Merge into: | lp:launchpad |
Diff against target: |
367 lines (+183/-11) 4 files modified
lib/canonical/launchpad/xmlrpc/faults.py (+17/-2) lib/lp/codehosting/puller/tests/test_scheduler.py (+0/-1) lib/lp/codehosting/vfs/branchfs.py (+51/-7) lib/lp/codehosting/vfs/tests/test_branchfs.py (+115/-1) |
To merge this branch: | bzr merge lp:~wallyworld/launchpad/codehost-error-trackback-leak |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Penhey (community) | Approve | ||
Graham Binns (community) | code | Approve | |
Review via email: mp+41685@code.launchpad.net |
Commit message
[r=gmb,
Description of the change
= Summary =
Bugs 674305 and 675517 relate to a situation whereby the xmlrpc server was misbehaving and bzr users who were trying to push or commit branches saw tracebacks printed on their consoles. This branch is to stop the traceback from being printed in front of the user - instead they get a message with an oops id.
= Implementation =
The problem was that the branchChanged() method on class LaunchpadServer merely added Twisted's log.err as an error callback to the relevant deferred instance:
return deferred.
log.err writes traceback info etc to stderr which I believe the smart server just catches and passes back to the user.
***
Actually, the above line was true when this branch was created. Creating this merge proposal resulted in conflicts in the diff and so after merging from trunk it is apparent there have been changes to Twisted infrastructure. log.err no longer outputs to stderr (when running the tests) so an explicit write to stderr has been added as well as doing the logging via log.err. I assume this changed behaviour of log.err will also be reflected in production.
***
So, what I've done is:
- create a new OopsOccurred(
- implement a new error handler which:
* creates an oops
* creates and returns an OopsOccurred instance
* use log.err and also write to stderr to record repr(OopsOccurred) so the user sees a nicer error message
The new oops logged by LaunchpadServer is the one whose oopid is reported to the user. The error report for this oops will contain a traceback and error message from the root cause xmlrpc error.
There are also a number of drive by lint fixes, mainly inserting newlines above method defs.
= Tests =
A new test class was added to TestBranchChang
bin/test -vvt test_branchfs
= Lint =
Linting changed files:
lib/canonical
lib/lp/
lib/lp/
./lib/lp/
1168: E501 line too long (81 characters)
1168: Line exceeds 78 characters.
Hi Ian,
A couple of comments but nothing major. We agreed on IRC that you'd
request a review from Thumper since I don't have enough domain knowledge
to judge whether your fix is the best way to do things.
> === modified file 'lib/canonical/ launchpad/ xmlrpc/ faults. py' launchpad/ xmlrpc/ faults. py 2010-07-02 12:10:21 +0000 launchpad/ xmlrpc/ faults. py 2010-11-27 05:11:16 +0000 __init_ _(self, openid_ identifier= openid_ identifier) LaunchpadFault) :
> --- lib/canonical/
> +++ lib/canonical/
> @@ -461,3 +462,15 @@
>
> def __init__(self, openid_identifier):
> LaunchpadFault.
> +
> +
> +class OopsOccurred(
> + """An oops has occurred performing the requested operation."""
> +
> + error_code = 380
> + msg_template = ('An unexpected error has occurred while %(server_op)s. '
> + 'Please report a Launchpad bug and quote: %(oopsid)s.')
Multi-line strings should start on the line after the declaration and by
indented by 4 spaces:
msg_template = (
'An unexpected error has occurred while %(server_op)s. '
'Please report a Launchpad bug and quote: %(oopsid)s.')
> === modified file 'lib/lp/ codehosting/ vfs/branchfs. py' codehosting/ vfs/branchfs. py 2010-09-22 18:32:22 +0000 codehosting/ vfs/branchfs. py 2010-11-27 05:11:16 +0000
> --- lib/lp/
> +++ lib/lp/
> @@ -141,7 +146,7 @@
> # directories that Bazaar creates as part of regular operation. We support
> # only two numbered backups to avoid indefinite space usage.
> ALLOWED_DIRECTORIES = ('.bzr', '.bzr.backup', 'backup.bzr', 'backup.bzr.~1~',
> - 'backup.bzr.~2~')
> + 'backup.bzr.~2~')
A nice tidy-up here would be to have each element in the tuple on its
own line, as we do with lists and dicts. The closing paren should go on
a separate line and the last element should be followed by a comma.
> FORBIDDEN_ DIRECTORY_ ERROR = ( nsport. _getUnderylingT ransportAndPath ( branch_ in_db(failure) : trap(NoSuchFile ) createBranch( self._abspath( relpath) ) (transport, path)): addCallback( got_path_ info).addErrbac k(log.err) error(failure= None, **kw):
> "Cannot create '%s'. Only Bazaar branches are allowed.")
>
> @@ -500,10 +505,12 @@
> # Launchpad branch.
> deferred = AsyncVirtualTra
> self, relpath)
> +
> def maybe_make_
> # Looks like we are trying to make a branch.
> failure.
> return self.server.
> +
> def real_mkdir(
> return getattr(transport, 'mkdir')(path, mode)
>
> @@ -687,10 +694,42 @@
> data['id'], stacked_on_url, last_revision,
> control_string, branch_string, repository_string)
>
> - # It gets really confusing if we raise an exception from this method
> - # (the branch remains locked, but this isn't obvious to the client) so
> - # just log the error, which will result in an OOPS being logged.
> - return deferred.
> + def handle_
> + # It gets really confusing if we raise an exception from this
> + # method (the branch remains locked, but this isn't obvious to
> + # the client). We could just log the failure using Twisted's
> + # log.err but thi...