From c7d13e62c7eea1369eaa65d9b3a7d109e2701d63 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 19 Nov 2021 17:15:52 -0800 Subject: [PATCH] Ensure output of mapper to unpack funcspec is a proto --- plugins/commands/serve/mappers.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/commands/serve/mappers.rb b/plugins/commands/serve/mappers.rb index 92d7caab4..44ff6a052 100644 --- a/plugins/commands/serve/mappers.rb +++ b/plugins/commands/serve/mappers.rb @@ -85,7 +85,7 @@ module VagrantPlugins def map(value, *extra_args, to: nil) # If we don't have a destination type provided, attempt # to set it using our default maps - to = DEFAULT_MAP[value.class] if to.nil? + to = DEFAULT_MAPS[value.class] if to.nil? logger.debug("starting the value mapping process #{value} => #{to.nil? ? 'unknown' : to.inspect}") if value.nil? && to @@ -236,17 +236,20 @@ module VagrantPlugins def unfuncspec(v) m = mappers.find_all { |map| map.inputs.size == 1 && + map.output.ancestors.include?(Google::Protobuf::MessageExts) && map.inputs.first.valid?(v) } if m.size > 1 raise TypeError, - "FuncSpec value of type `#{v.class}' matches more than one mapper" + "FuncSpec value of type `#{v.class}' matches more than one mapper (#{v})" end if m.empty? raise ArgumentError, "FuncSpec value of type `#{v.class}' has no valid mappers" end - m.first.call(v) + result = m.first.call(v) + logger.debug("converted funcspec argument #{v} -> #{result}") + result end end end