Open findmyname666 opened 6 months ago
Please try to reproduce this with version 5.7.0 or later; if it's still an issue we'll try to get it resolved.
Hey @kpfleming, I can confirm this issue still exists.
I looked into it a bit and the problem is the way wrapped_init
changes the response json keys into python keys.
The enabled-product APIs return an object with a key named "self"
. In change_keys_js_to_python
"self"
is converted to "_self"
. This makes it so that fn
is called with 2 _self
arguments.
This is an example response from the API as per the documentation
{
"product": {
"id": "product-id",
"object": "product"
},
"service": {
"id": "4nWURjwmQjbMB5OefSM75i",
"object": "service"
},
"_links": {
"self": "https://api.fastly.com/enabled-products/v1/product-id/services/4nWURjwmQjbMB5OefSM75i",
"service": "https://api.fastly.com/service/4nWURjwmQjbMB5OefSM75i"
}
}
The "self"
key in the _"links"
object is turned into "_self"
, which is then forwarded to fn
like so when deserializing it into the EnabledProductResponseLinks
-
return fn(_self, *args, **kwargs) # kwargs contains _self='...'
which causes the _self
argument to be passed into fn
multiple times.
I hope explained the issue clearly 😄
I don't mind opening a PR to fix this.
My first thought was to rename the _self
variable to _self_
in order to overcome the name collision. WDYT?
Thanks for finding the issue! We can't accept a PR directly against this repo as the code here is produced by a generator (in a private repository), but we can take these details and produce a fix for the generator.
@kpfleming Happy to help!
Version
Lib version:
5.2.0
.What happened
I tried to use Enable Product API but it is failing on type error when using multiple methods on instance class of
EnabledProductsApi
:The above error is raised also for python example code from the Fastly documentation.