Skip to content
Browse files

Make Release.from_tags() more predictable

If Release.from_tags() was called with a tag not associated with any
release, it would raise KeyError (unless an earlier tag in the list
was found first.) This was unexpected from the documentation - and was
handled by one caller but not others. Change it to return None in
this case - this was handled by all callers.

Signed-off-by: Owen W. Taylor <>
  • Loading branch information...
owtaylor authored and mergify committed Jun 12, 2018
1 parent 0ba628a commit 78dd4aaf08727aed194d496703f0f45171438f13
Showing with 3 additions and 10 deletions.
  1. +2 −0 bodhi/server/
  2. +1 −8 bodhi/server/
  3. +0 −2 bodhi/tests/server/services/
@@ -947,6 +947,8 @@ def from_tags(cls, tags, session):
tag_types, tag_rels = cls.get_tags(session)
for tag in tags:
if tag not in tag_rels:
release = session.query(cls).filter_by(name=tag_rels[tag]).first()
if release:
return release
@@ -155,14 +155,7 @@ def cache_release(request, build):
tags = cache_tags(request, build)
if tags is None:
return None
build_rel = None
build_rel = Release.from_tags(tags, request.db)
except KeyError:
log.warn('Unable to determine release from '
'tags: %r build: %r' % (tags, build))
request.errors.add('body', 'builds',
'Unable to determine release from build: %s' % build)
build_rel = Release.from_tags(tags, request.db)
if not build_rel:
msg = 'Cannot find release associated with ' + \
'build: {}, tags: {}'.format(build, tags)
@@ -872,8 +872,6 @@ def test_edit_add_build_from_different_release(self):
expected_json = {
u'status': u'error',
u'errors': [
{u'description': u'Unable to determine release from build: bodhi-3.2.0-1.fc27',
u'location': u'body', u'name': u'builds'},
{u'description': (
u"Cannot find release associated with build: bodhi-3.2.0-1.fc27, "
u"tags: [u'f27-updates-candidate', u'f27', u'f27-updates-testing']"),

0 comments on commit 78dd4aa

Please sign in to comment.
You can’t perform that action at this time.