New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rules: Return 404 when DID rules not found #6334 #6384
Rules: Return 404 when DID rules not found #6334 #6384
Conversation
01aa218
to
1fd25ec
Compare
Hi @alexanderrichards Thus, if an invalid (= non existent) did is given to the rest endpoint ( Now what makes this a bit special is that the core call: list_rules being used is a filter. So calling this normally with filter values, I would not expect it to raise a DIDNotFound, but in the specific circumstances how it is being instrumented in the REST endpoint, I would still expect the rest endpoint to raise that. So what I would do is at a existence check for the scope:name in the REST call. Thus a get_did call before. Hope that makes sense :-) Martin |
Hi @bari12, I understand. I can therefore put this check not in the core layer but either in the api layer (in |
Yes, that's the two options I see as well. My feeling is that this is a bit more accurate to be adressed in the REST layer directly. Thus in /dids/{scope_name}/rules you add the existence check of the did. It's not entirely wrong to do it in |
e0c3262
to
16bb6f9
Compare
looks like the changes are causing a test to fail because the mocked scope/name combination are clearly not found in the new
|
I think the problem here is that you need to add the VO into the rucio/lib/rucio/web/rest/flaskapi/v1/dids.py Line 550 in 16bb6f9
|
764293d
to
d01b01f
Compare
This PR fixes #6334.
The empty generator on the line
https://github.com/alexanderrichards/rucio/blob/01aa2184041e34584a82669ba846dfedfd8f0f51/lib/rucio/api/rule.py#L163
means that this generator never yields anything but neither does it raise an exception to get caught which would trigger a return value other than 200.
Instead of duplicating the generator and peeking I simply add a counter to see if it ever yields. If not then there were no rules and we can raise RuleNotFound.