Skip to content

Commit d16646c

Browse files
authored
Only forward the verbose property if it has been set (#5449)
## Change To prevent an error from attempting to parse a boolean from an empty string, only forward the diagnostics (verbose) property if it has been set.
1 parent aa15afb commit d16646c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/AppInstallerCLICore/ConfigurationDynamicRuntimeFactory.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ namespace AppInstaller::CLI::ConfigurationRemoting
130130
return m_processorEngine;
131131
}
132132

133-
winrt::hstring GetFactoryMapValue(winrt::hstring key)
133+
std::optional<winrt::hstring> GetFactoryMapValue(winrt::hstring key)
134134
{
135135
auto itr = m_factoryMapValues.find(key);
136-
return itr != m_factoryMapValues.end() ? itr->second : winrt::hstring{};
136+
return itr != m_factoryMapValues.end() ? std::make_optional(itr->second) : std::nullopt;
137137
}
138138

139139
private:
@@ -340,21 +340,21 @@ namespace AppInstaller::CLI::ConfigurationRemoting
340340
if (m_dynamicFactory->Engine() == ProcessorEngine::DSCv3)
341341
{
342342
winrt::hstring dscExecutablePathPropertyName = ToHString(PropertyName::DscExecutablePath);
343-
winrt::hstring dscExecutablePath = m_dynamicFactory->GetFactoryMapValue(dscExecutablePathPropertyName);
343+
std::optional<winrt::hstring> dscExecutablePath = m_dynamicFactory->GetFactoryMapValue(dscExecutablePathPropertyName);
344344

345-
if (dscExecutablePath.empty())
345+
if (!dscExecutablePath)
346346
{
347347
dscExecutablePath = m_dynamicFactory->Lookup(ToHString(PropertyName::FoundDscExecutablePath));
348348
}
349349

350-
if (dscExecutablePath.empty())
350+
if (dscExecutablePath->empty())
351351
{
352352
// This is backstop to prevent a case where dsc.exe not found.
353353
AICLI_LOG(Config, Error, << "Could not find dsc.exe, it must be provided by the user.");
354354
THROW_WIN32(ERROR_FILE_NOT_FOUND);
355355
}
356356

357-
json["processorPath"] = Utility::ConvertToUTF8(dscExecutablePath);
357+
json["processorPath"] = Utility::ConvertToUTF8(dscExecutablePath.value());
358358
}
359359

360360
Json::StreamWriterBuilder writerBuilder;
@@ -437,7 +437,10 @@ namespace AppInstaller::CLI::ConfigurationRemoting
437437
});
438438

439439
winrt::hstring propertyName = ConfigurationRemoting::ToHString(ConfigurationRemoting::PropertyName::DiagnosticTraceEnabled);
440-
factory.as<Collections::IMap<winrt::hstring, winrt::hstring>>().Insert(propertyName, m_dynamicFactory->GetFactoryMapValue(propertyName));
440+
if (auto propertyValue = m_dynamicFactory->GetFactoryMapValue(propertyName))
441+
{
442+
factory.as<Collections::IMap<winrt::hstring, winrt::hstring>>().Insert(propertyName, propertyValue.value());
443+
}
441444
}
442445

443446
return m_setProcessors.emplace(integrityLevel, DynamicProcessorInfo{ factory, factory.CreateSetProcessor(m_configurationSet), std::move(factoryDiagnosticsEventRevoker) }).first;

0 commit comments

Comments
 (0)