Skip to content

Commit

Permalink
Merge pull request #3652 from bari12/patch-3617-Clients__list_rules_s…
Browse files Browse the repository at this point in the history
…hould_raise_DIDNotFound_if_no_did

Clients: Raise DIDNotFound for list_rules if did does not exist; Fix #3617
  • Loading branch information
bari12 committed May 29, 2020
2 parents b219683 + 4d0a89e commit 8a614dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rucio/core/rule.py
Expand Up @@ -855,6 +855,7 @@ def list_associated_rules_for_file(scope, name, session=None):
:raises: RucioException
"""

rucio.core.did.get_did(scope=scope, name=name, session=session) # Check if the did acually exists
query = session.query(models.ReplicationRule).\
with_hint(models.ReplicaLock, "INDEX(LOCKS LOCKS_PK)", 'oracle').\
join(models.ReplicaLock, models.ReplicationRule.id == models.ReplicaLock.rule_id).\
Expand Down
4 changes: 3 additions & 1 deletion lib/rucio/web/rest/webpy/v1/did.py
Expand Up @@ -20,7 +20,7 @@
# - Mario Lassnig <mario.lassnig@cern.ch>, 2012-2018
# - Yun-Pin Sun <yun-pin.sun@cern.ch>, 2013
# - Cedric Serfon <cedric.serfon@cern.ch>, 2014-2018
# - Martin Baristis <martin.barisits@cern.ch>, 2014-2015
# - Martin Baristis <martin.barisits@cern.ch>, 2014-2020
# - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2018-2019
# - Ruturaj Gujar, <ruturaj.gujar23@gmail.com>, 2019
#
Expand Down Expand Up @@ -703,6 +703,8 @@ def GET(self, scope, name):
try:
for rule in list_associated_replication_rules_for_file(scope=scope, name=name):
yield dumps(rule, cls=APIEncoder) + '\n'
except DataIdentifierNotFound as error:
raise generate_http_error(404, 'DataIdentifierNotFound', error.args[0])
except RucioException as error:
raise generate_http_error(500, error.__class__.__name__, error.args[0])
except Exception as error:
Expand Down

0 comments on commit 8a614dd

Please sign in to comment.