@@ -254,8 +254,8 @@ def create_user_provided(message)
254254
255255 def create_managed ( message , space :)
256256 service_plan = ServicePlan . first ( guid : message . service_plan_guid )
257- log_service_plan_visibility ( service_plan )
258- unprocessable_service_plan! unless service_plan_valid? ( service_plan )
257+ service_plan_does_not_exist! unless service_plan
258+ service_plan_not_visible_to_user! ( service_plan ) unless visible_to_current_user? ( plan : service_plan )
259259 unavailable_service_plan! ( service_plan ) unless service_plan_active? ( service_plan )
260260 service_plan_not_visible_in_space! ( service_plan , space ) unless service_plan_exists_in_space? ( service_plan , space )
261261
@@ -397,11 +397,6 @@ def admin?
397397 permission_queryer . can_write_globally?
398398 end
399399
400- def service_plan_valid? ( service_plan )
401- service_plan &&
402- visible_to_current_user? ( plan : service_plan )
403- end
404-
405400 def service_plan_active? ( service_plan )
406401 service_plan . active?
407402 end
@@ -414,8 +409,8 @@ def raise_if_invalid_service_plan!(service_instance, message)
414409 return unless message . service_plan_guid
415410
416411 service_plan = ServicePlan . first ( guid : message . service_plan_guid )
417- log_service_plan_visibility ( service_plan )
418- unprocessable_service_plan! unless service_plan_valid? ( service_plan )
412+ service_plan_does_not_exist! unless service_plan
413+ service_plan_not_visible_to_user! ( service_plan ) unless visible_to_current_user? ( plan : service_plan )
419414 unavailable_service_plan! ( service_plan ) unless service_plan_active? ( service_plan )
420415 service_plan_not_visible_in_space! ( service_plan , service_instance . space ) unless service_plan_exists_in_space? ( service_plan , service_instance . space )
421416 invalid_service_plan_relation! unless service_plan . service == service_instance . service
@@ -433,7 +428,15 @@ def unprocessable_space!
433428 unprocessable! ( 'Invalid space. Ensure that the space exists and you have access to it.' )
434429 end
435430
436- def unprocessable_service_plan!
431+ def service_plan_does_not_exist!
432+ logger . info ( 'Service Plan does not exist.' )
433+ unprocessable! ( 'Invalid service plan. Ensure that the service plan exists, is available, and you have access to it.' )
434+ end
435+
436+ def service_plan_not_visible_to_user! ( service_plan )
437+ user = VCAP ::CloudController ::SecurityContext . current_user
438+ logger . info ( "Service Plan with guid '#{ service_plan . guid } ' and id '#{ service_plan . id } ' is not visible in current org to user with guid '#{ user . guid } '." )
439+
437440 unprocessable! ( 'Invalid service plan. Ensure that the service plan exists, is available, and you have access to it.' )
438441 end
439442
0 commit comments