Return empty response if capability returns an empty response

This commit is contained in:
sophia 2021-11-23 14:58:08 -06:00 committed by Paul Hinze
parent 46aa1b3e4e
commit 45cfcc4c34
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 13 additions and 2 deletions

View File

@ -80,8 +80,11 @@ module Vagrant
# #
# @return [Class] # @return [Class]
def host def host
if !@host
h = @client.host h = @client.host
Vagrant::Host.new(h, nil, nil, self) @host = Vagrant::Host.new(h, nil, nil, self)
end
@host
end end
# Gets a target (machine) by name # Gets a target (machine) by name

View File

@ -105,6 +105,14 @@ module VagrantPlugins
result = cap_method.call(*args) result = cap_method.call(*args)
logger.debug("got result #{result}")
if result.nil? || (result.respond_to?(:empty?) && result.empty?)
logger.debug("got empty result, returning empty response")
return SDK::Platform::Capability::Resp.new(
result: nil
)
end
val = Google::Protobuf::Value.new val = Google::Protobuf::Value.new
val.from_ruby(result) val.from_ruby(result)
SDK::Platform::Capability::Resp.new( SDK::Platform::Capability::Resp.new(