Skip to content

KeyError: 'depends' in _extract_depends_from_node

Summary

When parsing a .bst file that does not have a 'depends' entry, one gets the following error:

...
  File "/usr/lib/python3.7/site-packages/buildstream/_loader/loadelement.py", line 77, in __init__
    self.deps = _extract_depends_from_node(self.node)
  File "/usr/lib/python3.7/site-packages/buildstream/_loader/loadelement.py", line 169, in _extract_depends_from_node
    del node[Symbol.DEPENDS]
  File "/usr/lib/python3.7/site-packages/ruamel/yaml/comments.py", line 810, in __delitem__
    ordereddict.__delitem__(self, key)
KeyError: 'depends'

Note that this output comes from a released version of BuildStream but the same issue happens on the Git version.

Steps to reproduce

cd $(mktemp -d)
git clone https://gitlab.gnome.org/GNOME/gnome-build-meta.git
cd gnome-build-meta
bst build --track-all sdk/gtk+-3.bst

What is the current bug behavior?

Buildstream crashes.

What is the expected correct behavior?

BuildStream does not crash.

Possible fixes

https://gitlab.com/BuildStream/buildstream/blob/54d89aa1/buildstream/_loader/loadelement.py#L186

This line should be changed to

node.pop(key, None)

Other relevant information

  • BuildStream version affected: latest Git

Edited by Tristan Van Berkom
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information