From: Maxime Belanger <[email protected]>
Reply-To: "OpenStack Development Mailing List (not for usage questions)"
<[email protected]>
Date: Thursday, December 22, 2016 at 9:32 AM
To: "[email protected]" <[email protected]>
Subject: [openstack-dev] [Ironic] python-ironicclient weird behaviour
Hi Ironic folks,
Yesterday I come across a weird behaviour in python-ironicclient. I discussed
briefly with the problem with Julia and befor creating a bug I would like your
opinion on the problem and potential fix.
When doing nodes.get(resource_id=None), I get back a Node object set with
attribute nodes={nodes: [{uuid: 'blah'}, {uuid: 'bleh'}]}. I guess that is not
expected which is the bug I found and I know where to fix it if we agree to not
change the behavour: If resource_id=None the client is doing a GET on /v1/nodes
which is expected here :
https://github.com/openstack/python-ironicclient/blob/1.8.0/ironicclient/common/base.py#L55.
The thing is, returning the first item of the list while doing a get on
something that doesn't exists is a bit strange. I do not want to do extra
validation on my application side to not pass None to the ironicclient. I would
it to behave correctly: 404 or a even a 400.
What do you think/or prefer?
A. Fixing the bug and not changing actual behaviour of the API
B. Changing the API behaviour and returning a 404 error since resource None is
not found
C. Changing the API behaviour and returning a 400 error because None is not a
valid request. The will be identical to the command line that is doing this:
ironic node-show None
Invalid input for field/attribute node_ident. Value: 'None'. unable to convert
to uuid_or_name (HTTP 400)
Thanks
Max
Thanks for tripping over this! :-( I think this is a bug in the API. I think it
is just a coincidence that it happens to return the list of nodes (because the
generated HTTP request works). That code should be checking that resource_id is
non-empty -- that's what the CLI does. And if it isn't, raise an exception. I
vote for B, sort of. It shouldn't return an http status error since no http
request should be made. Looking at the existing exceptions, I'm guessing
InvalidAttribute or ValidationError?
Your C above is a different situation, 'None' is a string that is the name of a
node, but that string doesn't conform to the allowed name syntax.
--ruby
__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: [email protected]?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev