deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvl...@redhat.com
Subject [PATCH] DTACLOUD-457 RHEVm, Passing an invalid instance ID to start instance results in traceback with 500.
Date Fri, 08 Feb 2013 14:54:07 GMT
From: Joe VLcek <jvlcek@redhat.com>

---
 server/lib/deltacloud/helpers/deltacloud_helper.rb | 4 +++-
 server/views/errors/403.xml.haml                   | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud/helpers/deltacloud_helper.rb b/server/lib/deltacloud/helpers/deltacloud_helper.rb
index 4575ae2..bb023af 100644
--- a/server/lib/deltacloud/helpers/deltacloud_helper.rb
+++ b/server/lib/deltacloud/helpers/deltacloud_helper.rb
@@ -140,7 +140,9 @@ module Deltacloud::Helpers
     end
 
     def instance_action(name)
-      original_instance = driver.instance(credentials, :id => params[:id])
+      unless original_instance = driver.instance(credentials, :id => params[:id])
+        return report_error(403)
+      end
 
       # If original instance doesn't include called action
       # return with 405 error (Method is not Allowed)
diff --git a/server/views/errors/403.xml.haml b/server/views/errors/403.xml.haml
index 4b4cf23..274ce82 100644
--- a/server/views/errors/403.xml.haml
+++ b/server/views/errors/403.xml.haml
@@ -1,6 +1,7 @@
 %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
   %backend{ :driver => driver_symbol, :provider => "#{Thread::current[:provider] ||
ENV['API_PROVIDER'] || 'default'}" }
-  %backtrace=cdata(@error.backtrace.join("\n"))
+  - if @error.respond_to?(:backtrace) and !@error.backtrace.nil?
+    %backtrace=cdata(@error.backtrace.join("\n"))
   - if params
     %request
       - params.each do |k, v|
-- 
1.7.11.7


Mime
View raw message