martyzz1 / heroku3.py

This is the updated Python wrapper for the Heroku API V3. https://devcenter.heroku.com/articles/platform-api-reference The Heroku REST API allows Heroku users to manage their accounts, applications, addons, and other aspects related to Heroku. It allows you to easily utilize the Heroku platform from your applications.
Other
118 stars 73 forks source link

Wrong parameter passed to `ConfigVars.new_from_dict()` in `ConfigVars.update()` #53

Closed cans closed 6 years ago

cans commented 6 years ago

In the method ConfigVars.update() a new ConfigVars instance is built, with the values returned by the heroku API, and returned to the user. Yet that instance is not valid as the h keyword argument receives a ConfigVars instance instead of the expected Heroku instance (passed self instead of self._h).

Given that:

I would suggest that the API be modified as follows: the state of the ConfigVars instance should mutate it's internal dictionary (self.data) upon successful response from Heroku's API, and the method returns None.

cans commented 6 years ago

There are lots of similar oddities in that module's code:

config_vars = app.config()
d = config_vars.to_dict()  # or === config_vars.dict()
# From here on d and self.data reference the *same* mutable data structure !!
del d['SOME_SETTING']
if 'SOME_SETTING' not in config_vars:
    print('Oh My !')

Would print 'Oh My !'. I am not sure this is a good idea. One should copy the dictionary referenced by self.data before passing it on to the user. Otherwise, the state of the object is inconsistent with the actual state of the application as stored in Heroku infrastructure.

martyzz1 commented 6 years ago

Thanks Nicolas, this is really helpful, and appreciated.