AttributeError on parent.children in add when adding a symlink

Bug #192859 reported by Martin Pool
90
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Martin Pool
2.0
Fix Released
High
Unassigned
2.1
Fix Released
High
Unassigned
2.2
Fix Released
High
Unassigned
bzr (Ubuntu)
Fix Released
Undecided
Unassigned
Lucid
Fix Released
Undecided
Unassigned

Bug Description

Ian Grey <email address hidden> reports

added src/lndao/SensorDao.java
bzr: ERROR: exceptions.AttributeError: children

Traceback (most recent call last):
 File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
817, in run_bzr_catch_errors
   return run_bzr(argv)
 File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
779, in run_bzr
   ret = run(*run_argv)
 File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line
477, in run_argv_aliases
   return self.run(**all_cmd_args)
 File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 383, in run
   no_recurse, action=action, save=not dry_run)
 File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line
50, in tree_write_locked
   return unbound(self, *args, **kwargs)
 File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line
335, in smart_add
   added.extend(_add_one_and_parent(self, inv, None, rf, kind, action))
 File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line
502, in _add_one_and_parent
   _add_one(tree, inv, parent_ie, path, kind, action)
 File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line
519, in _add_one
   inv.add(entry)
 File "/usr/lib/python2.5/site-packages/bzrlib/inventory.py", line 1159, in add
   if entry.name in parent.children:
AttributeError: children

bzr 0.90.0 on python 2.5.1.final.0 (linux2)
arguments: ['/usr/bin/bzr', 'add', 'src/lndao/SensorDao.java']

** please send this report to <email address hidden>

Note that src/lndao/SensorDao.java is a symlink to
src/dao/com/redacted/redacted/service/SensorDao.java, and
src/dao/redacted/redacted/service/ is under bzr control. Just in case
that has something to do with it.

Related branches

Revision history for this message
Martin Pool (mbp) wrote :

The line referencing parent.child is still present post 1.2 so it's possible this bug is still live.

Revision history for this message
Joey Stanford (joey) wrote :
Download full text (3.2 KiB)

I have what appears to be the same blocking problem:

joey@c14n:~/helpwikitheme$ bzr commit -m"reordered to match production" > /home/joey/bzrcommiterror.txt
Committing to: /home/joey/helpwikitheme/
modified htdocs/lp1_0theme
added htdocs/lphelpwiki
bzr: ERROR: exceptions.AttributeError: children

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 834, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 790, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 2329, in run
    author=author)
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 246, in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/mutabletree.py", line 187, in commit
    revprops=revprops, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 355, in commit
    self._update_builder_with_changes()
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 656, in _update_builder_with_changes
    self._populate_from_inventory(specific_files)
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 784, in _populate_from_inventory
    content_summary)
  File "/usr/lib/python2.5/site-packages/bzrlib/commit.py", line 826, in _record_entry
    self.parent_invs, path, self.work_tree, content_summary)
  File "/usr/lib/python2.5/site-packages/bzrlib/repository.py", line 266, in record_entry_contents
    self.new_inventory.add(ie)
  File "/usr/lib/python2.5/site-packages/bzrlib/inventory.py", line 1185, in add
    if entry.name in parent.children:
AttributeError: children

bzr 1.2.0 on python 2.5.1.final.0 (linux2)
arguments: ['/usr/bin/bzr', 'commit', '-mreordered to match production']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_US.UTF-8'
plugins:
  bzr_branchfeed /home/joey/.bazaar/plugins/bzr_branchfeed [unknown]
  bzrtools /usr/lib/python2.5/site-packages/bzrlib/plugins/bzrtools [1.2.0]
  gnulog /home/joey/.bazaar/plugins/gnulog.py [unknown]
  gtk /usr/lib/python2.5/site-packages/bzrlib/plugins/gtk [0.93.0]
  htmllog /home/joey/.bazaar/plugins/htmllog [unknown]
  launchpad /usr/lib/python2.5/site-packages/bzrlib/plugins/launchpad [unknown]
  lpreview /home/joey/.bazaar/plugins/lpreview [unknown]
  pqm /usr/lib/python2.5/site-packages/bzrlib/plugins/pqm [0.92.0]
  stats /home/joey/.bazaar/plugins/stats [unknown]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what y...

Read more...

James Westby (james-w)
Changed in bzr:
importance: Undecided → High
status: New → Confirmed
Martin Pool (mbp)
Changed in bzr:
milestone: none → 2.2.0
Revision history for this message
Martin Pool (mbp) wrote :

This can be reproduced in 2.3.0dev with

mbp@lithe% ls -o
total 0
lrwxrwxrwx 1 mbp 1 2010-07-15 11:54 a -> c
mbp@lithe% bzr st
mbp@lithe% mkdir c
mbp@lithe% bzr
mbp@lithe% touch c/d
mbp@lithe% bzr add c
adding c
adding c/d
mbp@lithe% bzr rm --keep c/d
removed c/d
mbp@lithe% bzr add a/d
adding a/d
bzr: ERROR: exceptions.AttributeError: children

Traceback (most recent call last):
  File "/home/mbp/bzr/trunk/bzrlib/commands.py", line 911, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/home/mbp/bzr/trunk/bzrlib/commands.py", line 1111, in run_bzr
    ret = run(*run_argv)
  File "/home/mbp/bzr/trunk/bzrlib/commands.py", line 689, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/mbp/bzr/trunk/bzrlib/commands.py", line 704, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/home/mbp/bzr/trunk/bzrlib/cleanup.py", line 135, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/home/mbp/bzr/trunk/bzrlib/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/home/mbp/bzr/trunk/bzrlib/builtins.py", line 690, in run
    no_recurse, action=action, save=not dry_run)
  File "/home/mbp/bzr/trunk/bzrlib/mutabletree.py", line 49, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/home/mbp/bzr/trunk/bzrlib/mutabletree.py", line 440, in smart_add
    added.extend(_add_one_and_parent(self, inv, None, rf, kind, action))
  File "/home/mbp/bzr/trunk/bzrlib/mutabletree.py", line 704, in _add_one_and_parent
    _add_one(tree, inv, parent_ie, path, kind, action)
  File "/home/mbp/bzr/trunk/bzrlib/mutabletree.py", line 721, in _add_one
    inv.add(entry)
  File "/home/mbp/bzr/trunk/bzrlib/inventory.py", line 1301, in add
    if entry.name in parent.children:
AttributeError: children

(working on a minimum reproduction)

Changed in bzr:
assignee: nobody → Martin Pool (mbp)
status: Confirmed → In Progress
Revision history for this message
Martin Pool (mbp) wrote :

There's a related problem which is that you can sometimes end up with a file apparently living under a symlink:

mbp@lithe% cd 192859-2
mbp@lithe% mkdir c
mbp@lithe% ln -s c a
mbp@lithe% touch c/cc
mbp@lithe% bzr add c
adding c
mbp@lithe% bzr add a/d
mbp@lithe% touch c/d
mbp@lithe% bzr add a/d
adding a
adding a/d
mbp@lithe% ls -oR
.:
total 8
lrwxrwxrwx 1 mbp 1 2010-07-15 11:57 a -> c/
drwxr-xr-x 2 mbp 4096 2010-07-15 11:57 c/

./c:
total 0
-rw-r--r-- 1 mbp 0 2010-07-15 11:57 d
mbp@lithe% bzr inventory
a
a/d
c

Revision history for this message
Martin Pool (mbp) wrote :

So I think there's two bugs (or two failure cases):

- if the symlink is previously added, and then we try to add a child, we get an attributeerror because there's a symlink inventory entry but it does not support children
- if the symlink is not already added, then the "implicitly add parents" rule will add the symlink implicitly as a directory, even though it actually is not

Revision history for this message
Martin Pool (mbp) wrote :

https://bugs.edge.launchpad.net/bzr/+bug/240762 is similar but happening during merge

bug 341555 is basically the same as the first case: the working inventory holds a symlink entry, but now it's changed to be a directory, therefore it can have children

Just doing 'bzr st' will fix the situation because that re-checks the kind of all wt entries.

In a way the root problem here is that the dirstate column 0 has a 'kind' value: if it's different to what's actually on disk then it's the external reality that is correct.

Revision history for this message
Martin Pool (mbp) wrote :

Cases to consider:

 'bzr add path/symlink' should add the symlink (as a symlink)
 'bzr add path/symlink/contained' should add 'contained' (bearing in mind it may be a path, symlink or file), or give a clear error if the symlink points outside the tree

after changing a symlink 'a' to a directory or vice versa

 - can commit
 - can add: with no parameters, 'add a', and 'add a/b'
 - can run status (probably works now) or diff etc

This possibly needs to be tested per wt format.

Another case:

  mv dir other
  ln -s other dir

If you don't do 'bzr mv dir other' but just move the directory, the children should all show up as missing - even though you will be able to stat them at the original path.

Revision history for this message
Martin Pool (mbp) wrote :

TestKindChanges in the attached branch reproduces one of these cases:

<class 'testtools.testresult.real._StringException'>: Text attachment: traceback
------------
Traceback (most recent call last):
  File "/home/mbp/bzr/192859-2.0-symlinks/bzrlib/tests/per_workingtree/test_symlinks.py", line 84, in test_symlink_to_dir
    tree.smart_add(['tree/a/f'])
  File "/home/mbp/bzr/192859-2.0-symlinks/bzrlib/mutabletree.py", line 53, in tree_write_locked
    return unbound(self, *args, **kwargs)
  File "/home/mbp/bzr/192859-2.0-symlinks/bzrlib/mutabletree.py", line 417, in smart_add
    added.extend(_add_one_and_parent(self, inv, None, rf, kind, action))
  File "/home/mbp/bzr/192859-2.0-symlinks/bzrlib/mutabletree.py", line 671, in _add_one_and_parent
    _add_one(tree, inv, parent_ie, path, kind, action)
  File "/home/mbp/bzr/192859-2.0-symlinks/bzrlib/mutabletree.py", line 688, in _add_one
    inv.add(entry)
  File "/home/mbp/bzr/192859-2.0-symlinks/bzrlib/inventory.py", line 1300, in add
    if entry.name in parent.children:
AttributeError: children
------------

Revision history for this message
Martin Pool (mbp) wrote :

I think the two attached mps fix every case of this. Contradictions welcome.

John A Meinel (jameinel)
Changed in bzr:
status: In Progress → Fix Released
Revision history for this message
Andrew Bennetts (spiv) wrote :

Current status is that the fixes have landed in the lp:bzr/2.0 branch and will be part of 2.0.6, but hasn't yet been merged up into 2.1, 2.2 or trunk. It most likely will be part of 2.1.3 and 2.2.1.

I've updated the individual milestones accordingly.

Revision history for this message
Clint Byrum (clint-fewbar) wrote : Please test proposed package

Accepted bzr into lucid-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in bzr (Ubuntu Lucid):
status: New → Fix Committed
tags: added: verification-needed
Jelmer Vernooij (jelmer)
Changed in bzr (Ubuntu):
status: New → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package bzr - 2.1.4-0ubuntu1

---------------
bzr (2.1.4-0ubuntu1) lucid-proposed; urgency=low

  * Update watch file to use 2.1 series.
  * New upstream release.
   + Fix file descriptors leaks in dirstate compiled extension. LP: #583486
   + Refuse to stack on repositories in incompatible formats. LP: #562380
   + Don't delete nested trees/repos. LP: #572098
   + Fix 'bzr switch' crash when a 'ConfigurableFileMerger' is used. LP: #559436
   + Fix compatibility with older smart servers. LP: #528041
   + Fix symlinks addition. LP: #192859
   + Properly unversion children of unversioned directories. LP: #494221
   + Lock configuration files in '~/.bazaar' for updates. LP: #525571
   + Fix 'bzr commit <symlink>'. LP: #128562
   + Fix `lp:` urls when behind an http proxy. LP: #558343
   + Stop using edge.launchpad.net. LP: #583667
 -- Max Bowsher <email address hidden> Tue, 17 May 2011 09:54:17 +0100

Changed in bzr (Ubuntu Lucid):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.