Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix webapi accountless crash #760

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

`Added` Security groups support to the OpenVNet integration.

`Fixed` A bug where the WebAPI would crash when no account id was set in a request. It now fails gracefully with a 400 error instead.

`Fixed` A crash that occurred when performing a POST request to the ssh_key_pairs endpoint without including the "public_key" field in the parameters.

`Fixed` A bug in the `lxc-start` command generation, causing LXC instances to crash on startup.
Expand Down
3 changes: 2 additions & 1 deletion dcmgr/lib/dcmgr/endpoints/12.03/core_api.rb
Expand Up @@ -56,8 +56,9 @@ class CoreAPI < Sinatra::Base

before do
requester_account_id = request.env[HTTP_X_VDC_ACCOUNT_UUID]

if requester_account_id.nil?
@account = nil
raise E::AccountIdNotSet, 'No account id was set in the HTTP headers.'
else
begin
# find or create account entry.
Expand Down
1 change: 1 addition & 0 deletions dcmgr/lib/dcmgr/endpoints/errors.rb
Expand Up @@ -178,5 +178,6 @@ def self.set_error_code_type(error_code, klass)
define_error(:UnknownEvaluationPeriods, 400, '199')
define_error(:UnknownNotificationPeriods, 400, '200')
define_error(:PasswordNotInDatabase, 410, '201')
define_error(:AccountIdNotSet, 400, '202')
end
end