You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
There are two cases that could probably be patched and prevented:
Try to create 0 or fewer processes of a new type
e.g. app.processes.add('web', 0)
Try to scale to a number of dynos that's not an integer (whether that process type is currently running or not)
e.g. app.processes['web'].scale('aaa')
The Heroku Toolbelt prevents these from happening, so I'm guessing you guys like to prevent this behaviour :) However, both of these calls currently throw a KeyError:
File "/app/.heroku/venv/lib/python2.7/site-packages/heroku/structures.py", line 55, in add
return self[0].new(*args, **kwargs)
File "/app/.heroku/venv/lib/python2.7/site-packages/heroku/models.py", line 515, in new
return self.app.processes[type]
File "/app/.heroku/venv/lib/python2.7/site-packages/heroku/structures.py", line 106, in __getitem__
raise why
KeyError: 'web'
Now we could add code inside Process.scale() and Process.new() to check for non-integers and quantities < 1. However it seems like The Heroku Way in this module is to try taking actions and raise errors if they don't work? Also on the HEAD branch if we try to scale a process to a number of dynos that's < 1 we get this response from the server:
File "/app/.heroku/venv/lib/python2.7/site-packages/heroku/structures.py", line 46, in add
return self[0].new(_args, *_kwargs)
File "/app/.heroku/venv/lib/python2.7/site-packages/heroku/models.py", line 505, in new
data={'type': type, 'qty': quantity}
File "/app/.heroku/venv/lib/python2.7/site-packages/heroku/api.py", line 103,in _http_resource
raise http_error
requests.exceptions.HTTPError: 422 Client Error: {"error":"Cannot scale to fewer than 0 dynos per process type."}
So perhaps you'd prefer to write server code to deal with these situations instead, which will then get caught by the calls to r.raise_for_status() in both Process.new() and Process.scale()
Let me know! :)
The text was updated successfully, but these errors were encountered:
There are two cases that could probably be patched and prevented:
e.g. app.processes.add('web', 0)
e.g. app.processes['web'].scale('aaa')
The Heroku Toolbelt prevents these from happening, so I'm guessing you guys like to prevent this behaviour :) However, both of these calls currently throw a KeyError:
Now we could add code inside Process.scale() and Process.new() to check for non-integers and quantities < 1. However it seems like The Heroku Way in this module is to try taking actions and raise errors if they don't work? Also on the HEAD branch if we try to scale a process to a number of dynos that's < 1 we get this response from the server:
File "/app/.heroku/venv/lib/python2.7/site-packages/heroku/structures.py", line 46, in add
return self[0].new(_args, *_kwargs)
File "/app/.heroku/venv/lib/python2.7/site-packages/heroku/models.py", line 505, in new
data={'type': type, 'qty': quantity}
File "/app/.heroku/venv/lib/python2.7/site-packages/heroku/api.py", line 103,in _http_resource
raise http_error
requests.exceptions.HTTPError: 422 Client Error: {"error":"Cannot scale to fewer than 0 dynos per process type."}
So perhaps you'd prefer to write server code to deal with these situations instead, which will then get caught by the calls to r.raise_for_status() in both Process.new() and Process.scale()
Let me know! :)
The text was updated successfully, but these errors were encountered: