#124 closed defect (fixed)

exceptions when trying to use dirnode URIs

Reported by: zooko Owned by: warner
Priority: major Milestone: 0.6.0
Component: code Version: 0.5.1
Keywords: Cc:
Launchpad Bug:

Description (last modified by zooko)

poor handling of user error: pasting a dirnode uri into the "get file" field of the wui

If you paste a dirnode uri into the "URI of file to download" field, you'll get:

An error occurred rendering the requested page. Additionally, an error occured rendering the error page.

The twistd.log contains:

          File "/Users/wonwinmcbrootles/playground/allmydata/tahoe/instdir/lib/allmydata/vdrive.py", line 128, in get_node
            node_uri = IURI(node_uri)
            # node_uri = "' URI:DIR:pb://xextf3eap44o3wi27mf7ehiur6wvhzr6@207.7.153.180:56677,127.0.0.1:56677/vdrive:y1obs85cazf
aa8uyd8mb1u8esw'"
            # IURI = '<InterfaceClass allmydata.interfaces.IURI>'
          File "/lib/python2.5/site-packages/zope/interface/interface.py", line 697, in __call__
            
          File "/lib/python2.5/site-packages/zope/interface/interface.py", line 765, in __adapt__
            
          File "/usr/local/stow/Twisted-2.5.0/lib/python2.5/site-packages/twisted/python/components.py", line 113, in _hook
            return factory(ob)
            # ob = "' URI:DIR:pb://xextf3eap44o3wi27mf7ehiur6wvhzr6@207.7.153.180:56677,127.0.0.1:56677/vdrive:y1obs85cazfaa8uyd
8mb1u8esw'"
          File "/Users/wonwinmcbrootles/playground/allmydata/tahoe/instdir/lib/allmydata/uri.py", line 205, in from_string
            raise RuntimeError("unknown URI type: %s.." % s[:10])
            # RuntimeError = "<type 'exceptions.RuntimeError'>"
            # s = "' URI:DIR:pb://xextf3eap44o3wi27mf7ehiur6wvhzr6@207.7.153.180:56677,127.0.0.1:56677/vdrive:y1obs85cazfaa8uyd8
mb1u8esw'"
        exceptions.RuntimeError: unknown URI type:  URI:DIR:p..

and

          File "/usr/local/lib/python2.5/site-packages/nevow/appserver.py", line 82, in processingFailed
            handler.renderHTTP_exception(ctx, reason)
          File "/usr/local/lib/python2.5/site-packages/nevow/appserver.py", line 57, in renderHTTP_exception
            result = failure.formatFailure(reason)
            # reason = <twisted.python.failure.Failure <type 'exceptions.RuntimeError'>>
          File "/usr/local/stow/Nevow-0.9.18/lib/python2.5/site-packages/nevow/failure.py", line 248, in formatFailure
            for method, filename, lineno, localVars, globalVars in myFailure.frames:
            # myFailure = <twisted.python.failure.Failure <type 'exceptions.RuntimeError'>>

Ah, the same thing happens when I paste the dirnode uri into the "URI of new child" field!

Here is the twistd.log from that:

          File "/Users/wonwinmcbrootles/playground/allmydata/tahoe/instdir/lib/allmydata/dirnode.py", line 282, in set_uri
            write, read = self._split_uri(child_uri)
            # self = '<allmydata.dirnode.MutableDirectoryNode instance at 0x20e3170>'
            # child_uri = "' URI:DIR:pb://xextf3eap44o3wi27mf7ehiur6wvhzr6@207.7.153.180:56677,127.0.0.1:56677/vdrive:y1obs85caz
faa8uyd8mb1u8esw'"
          File "/Users/wonwinmcbrootles/playground/allmydata/tahoe/instdir/lib/allmydata/dirnode.py", line 306, in _split_uri
            u = IURI(child_uri)
            # IURI = '<InterfaceClass allmydata.interfaces.IURI>'
            # child_uri = "' URI:DIR:pb://xextf3eap44o3wi27mf7ehiur6wvhzr6@207.7.153.180:56677,127.0.0.1:56677/vdrive:y1obs85caz
faa8uyd8mb1u8esw'"
          File "/lib/python2.5/site-packages/zope/interface/interface.py", line 697, in __call__
            
          File "/lib/python2.5/site-packages/zope/interface/interface.py", line 765, in __adapt__
            
          File "/usr/local/stow/Twisted-2.5.0/lib/python2.5/site-packages/twisted/python/components.py", line 113, in _hook
            return factory(ob)
            # ob = "' URI:DIR:pb://xextf3eap44o3wi27mf7ehiur6wvhzr6@207.7.153.180:56677,127.0.0.1:56677/vdrive:y1obs85cazfaa8uyd
8mb1u8esw'"
          File "/Users/wonwinmcbrootles/playground/allmydata/tahoe/instdir/lib/allmydata/uri.py", line 205, in from_string
            raise RuntimeError("unknown URI type: %s.." % s[:10])
            # RuntimeError = "<type 'exceptions.RuntimeError'>"
            # s = "' URI:DIR:pb://xextf3eap44o3wi27mf7ehiur6wvhzr6@207.7.153.180:56677,127.0.0.1:56677/vdrive:y1obs85cazfaa8uyd8
mb1u8esw'"
        exceptions.RuntimeError: unknown URI type:  URI:DIR:p..
        

Change History (7)

comment:1 Changed at 2007-08-24T15:44:54Z by zooko

  • Component changed from unknown to code-frontend-web
  • Owner nobody deleted

comment:2 Changed at 2007-08-24T15:47:31Z by zooko

  • Component changed from code-frontend-web to code
  • Description modified (diff)
  • Owner set to somebody
  • Summary changed from poor handling of user error: pasting a dirnode uri into the "get file" field of the wui to exceptions when trying to use dirnode URIs

comment:3 Changed at 2007-08-25T00:32:36Z by warner

  • Owner changed from somebody to warner
  • Status changed from new to assigned

The first is a user error, but the error message obviously needs improvement.

The second ought to have worked. Odd, it worked for me just now..

I'll look at the error message more closely. BTW, what version of the node were you running?

comment:4 Changed at 2007-08-25T00:38:17Z by warner

Hooray for bindann!

# s = "' URI:DIR:pb://xextf3eap44o3wi27mf7ehiur6wvhzr6@207.7.153.180:56677,127.0.0.1:56677/vdrive:y1obs85cazfaa8uyd8
mb1u8esw'"

well, ok, the extra quotes are weird, I don't know whether those are an artifact or not, but the leading space is the problem. There must have been a space in the text field when you pasted the URI in, or the cut target must have had a space in it.

I'm going to change webish.py to do a strip() on all the arguments that it receives. This is obviously correct for URIs. For filenames, it isn't, but I think it is the least surprising approach (imagine adding a filename that is all spaces, or a filename with a trailing space, and then trying to access it via the CLI!).

comment:5 Changed at 2007-08-25T02:52:24Z by zooko

(imagine adding a filename that is all spaces, or a filename with a trailing space, and then trying to access it via the CLI!).

That's easy! You just have to quote or escape it. :-)

comment:6 Changed at 2007-08-25T19:21:33Z by warner

  • Milestone changed from undecided to 0.6.0
  • Resolution set to fixed
  • Status changed from assigned to closed

true, but display is a problem: before I got into the habit of using tab-completion everywhere, I'd spend entire minutes trying to figure out why the file that 'ls' is showing me couldn't be deleted (because ls was unable to tell me that there was a space at the end of the filename).

I've fixed these in 5946985c0789ca5d and ed525f74780159c2 (separately in case we decide that stripping filenames is a bad idea).

The first problem (pasting a dirnode URI into the 'download file' box) suggests that maybe we should have a "View a directory" box on the front page, that accepts a dirnode URI. Or maybe we should have a "do something useful with a URI" box that accepts either, although the filename parameter is still a nuisance.

Thinking about this more carefully, the real issue is one of typing. When a user shares a file or directory, they're using an edge of their own vdrive graph to identify it, so they have some idea in mind of how they want the data (sequence of bytes) that they're sharing to be used. I see five cases: sharing just bytes (with no type information), sharing bytes + mime-type, sharing bytes + mime-type + suggested filename, sharing a directory, sharing a directory + suggested dirname.

Our current URI syntax collapses the type information into one bit: filenode or dirnode. Filenodes can be treated as a variety of mime-types, but that information is in the edge (implied by the filename).

Hm, maybe the box on the front page should accept a "sharing link", which is more than a URI, maybe a URI combined with some information about suggested filename/dirname.

Anyways, I'm going to close this one out. Zooko, do you think the front-page box I just described is useful? I'm not so sure. If you think it is, we can open a new ticket for it.

comment:7 Changed at 2007-08-27T12:32:43Z by zooko

true, but display is a problem: before I got into the habit of using tab-completion everywhere, I'd spend entire minutes trying to figure out why the file that 'ls' is showing me couldn't be deleted (because ls was unable to tell me that there was a space at the end of the filename).

I guess this means that "ls" ought to display the result in quotes, right?

Note: See TracTickets for help on using tickets.