Closed antoineco closed 7 years ago
Converting to ?region=null
would make more sense to you ?
For me, if you have region: None
in your parameters means you want explicitely to send it to the API. As we can't assume that the default value for a parameter is equal to null
(if you don't send it), it could lead to some misunderstanding. Don't you think ?
@Rbeuque74 I think I'd rather send nothing than the 'null'
string, but it depends how the API handles it. Do you know how key=null
differs from not sending anything?
My understanding is that if you explicitly want to send the 'null'
string you should do it on your side, but if your parameter's value is None
(I'm talking about an actual NoneType
) you'd better ignore it. You said it yourself, you don't know if the default for the parameter is ' null', so if you send nothing you actually respect the default.
The correct way of fixing this issue is to send null
rather than None
. As @Rbeuque74 said, the API engine has no way to differentiate a "is null" filter from a "ignore" filter if not explicitly told. This is how the reference implementation works https://api.ovh.com/console/#/cloud/project#GET
Hence, there are 2 fixes here:
👍 encoding the param with a null
value sounds good to me, thanks for the commit. I'm still unsure how /endpoint?region=null
differs from /endpoint
but at least it's explicit.
btw, the coveralls
step fails in Travis.
The following example will fail if
region
isNone
, because eventually{ 'foo': None }
will be returned as'foo=None'
byurlencode()
and'None'
is not a valid value:throws:
ovh.exceptions.BadParametersError: Invalid region parameter
It sounds safe to me to exclude
None
values in theclient._prepare_query_string()
method because I doubt it's ever intentional to have aNoneType
converted to the'None'
string in this context.Besides we might end up with an empty
query_string
if the originalkwargs
contained onlyNone
values, so I included a condition for that in a second commit to avoid the following exception:_target
was/cloud/project/<projectid>/flavor?