bad error message when you give a readonly dircap as target to "tahoe cp" #2081

Open
opened 2013-09-11 06:09:01 +00:00 by zooko · 4 comments

I accidentally wrote tahoe cp -r . $RODIRCAP, and instead of a nice error message like "Can't cp to target because it is read-only.", I got this:


zooko@spark ~/tmp/tahoe-lafs.org/~zooko $ tahoe cp --node-directory=~/.tahoe-basedirs/leastauthority-zookog_at_gmail.com/gateway/ -r ./backup_of_klog/ $RODIRCAP
Traceback (most recent call last):
  File "/usr/bin/tahoe", line 3, in <module>
    runner.run()
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/runner.py", line 113, in run
    rc = runner(sys.argv[1:], install_node_control=install_node_control)
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/runner.py", line 99, in runner
    rc = cli.dispatch[command](so)
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/cli.py", line 546, in cp
    rc = tahoe_cp.copy(options)
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 771, in copy
    return Copier().do_copy(options)
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 451, in do_copy
    status = self.try_copy()
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 512, in try_copy
    return self.copy_to_directory(sources, target)
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 658, in copy_to_directory
    self.assign_targets(source, target)
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 693, in assign_targets
    subtarget = target.get_child_target(name)
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 378, in get_child_target
    writecap = make_tahoe_subdirectory(self.nodeurl, self.writecap, name)
  File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 55, in make_tahoe_subdirectory
    ]) + "?t=mkdir"
  File "/usr/lib/python2.7/urllib.py", line 1255, in quote
    raise TypeError('None object cannot be quoted')
TypeError: None object cannot be quoted
I accidentally wrote `tahoe cp -r . $RODIRCAP`, and instead of a nice error message like "Can't cp to target because it is read-only.", I got this: ``` zooko@spark ~/tmp/tahoe-lafs.org/~zooko $ tahoe cp --node-directory=~/.tahoe-basedirs/leastauthority-zookog_at_gmail.com/gateway/ -r ./backup_of_klog/ $RODIRCAP Traceback (most recent call last): File "/usr/bin/tahoe", line 3, in <module> runner.run() File "/usr/lib/python2.7/dist-packages/allmydata/scripts/runner.py", line 113, in run rc = runner(sys.argv[1:], install_node_control=install_node_control) File "/usr/lib/python2.7/dist-packages/allmydata/scripts/runner.py", line 99, in runner rc = cli.dispatch[command](so) File "/usr/lib/python2.7/dist-packages/allmydata/scripts/cli.py", line 546, in cp rc = tahoe_cp.copy(options) File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 771, in copy return Copier().do_copy(options) File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 451, in do_copy status = self.try_copy() File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 512, in try_copy return self.copy_to_directory(sources, target) File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 658, in copy_to_directory self.assign_targets(source, target) File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 693, in assign_targets subtarget = target.get_child_target(name) File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 378, in get_child_target writecap = make_tahoe_subdirectory(self.nodeurl, self.writecap, name) File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 55, in make_tahoe_subdirectory ]) + "?t=mkdir" File "/usr/lib/python2.7/urllib.py", line 1255, in quote raise TypeError('None object cannot be quoted') TypeError: None object cannot be quoted ```
zooko added the
code-mutable
normal
defect
1.10.0
labels 2013-09-11 06:09:01 +00:00
zooko added this to the undecided milestone 2013-09-11 06:09:01 +00:00
daira commented 2014-01-03 21:35:00 +00:00
Owner

multikatt proposed a pull request at https://github.com/tahoe-lafs/tahoe-lafs/pull/83. My comment was:

Presumably similar issues apply to other commands besides tahoe cp (tahoe mv at least), but the proposed fix is specific to cp. Also, the method of detecting that the cap is a read cap will work but I find it a bit dissatisfying; it gives me the feeling of working for the wrong reason.

multikatt proposed a pull request at <https://github.com/tahoe-lafs/tahoe-lafs/pull/83>. My comment was: Presumably similar issues apply to other commands besides `tahoe cp` (`tahoe mv` at least), but the proposed fix is specific to `cp`. Also, the method of detecting that the cap is a read cap will work but I find it a bit dissatisfying; it gives me the feeling of working for the wrong reason.
daira commented 2014-01-03 21:37:04 +00:00
Owner

(The method of detecting a read cap used by the pull request was to check whether the "ro_uri" field of the target directory node's JSON description was the same URI as its main cap.)

(The method of detecting a read cap used by the pull request was to check whether the "ro_uri" field of the target directory node's JSON description was the same URI as its main cap.)
daira commented 2014-01-03 21:43:21 +00:00
Owner

Note that in the traceback, the issue seems to be that self.writecap is None here:

File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 378, in get_child_target
    writecap = make_tahoe_subdirectory(self.nodeurl, self.writecap, name)

I would prefer to see a patch that maintained the invariant that self.writecap is not None whenever the node must be writeable.

Note that in the traceback, the issue seems to be that `self.writecap` is `None` here: ``` File "/usr/lib/python2.7/dist-packages/allmydata/scripts/tahoe_cp.py", line 378, in get_child_target writecap = make_tahoe_subdirectory(self.nodeurl, self.writecap, name) ``` I would prefer to see a patch that maintained the invariant that `self.writecap` is not `None` whenever the node must be writeable.
daira commented 2014-05-02 23:39:37 +00:00
Owner

multikatt's pull request has been closed; I assume they're not working on it currently.

multikatt's pull request has been closed; I assume they're not working on it currently.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

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