Github user phrocker commented on a diff in the pull request:
https://github.com/apache/nifi-minifi-cpp/pull/350#discussion_r192165204
--- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp ---
@@ -782,29 +783,59 @@ void
YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode,
}
}
+ validateComponentProperties(processor, component_name, yaml_section);
+}
+
+void YamlConfiguration::validateComponentProperties(const
std::shared_ptr<ConfigurableComponent> &component,
+ const std::string
&component_name,
+ const std::string
&yaml_section) const {
+ const auto &component_properties = component->getProperties();
+
// Validate required properties
- for (const auto &prop_pair : processor->getProperties()) {
+ for (const auto &prop_pair : component_properties) {
if (prop_pair.second.getRequired()) {
- const auto &val = prop_pair.second.getValue();
-
- if (val.empty()) {
- // Build a helpful error message for the user so they can fix the
- // invalid YAML config file, using the component name if present
- std::string err_msg =
- "Unable to parse configuration file for component named '"
- + component_name
- + "' because required property '" +
prop_pair.second.getName() + "' is not set";
- if (!yaml_section.empty()) {
- err_msg += " [in '" + yaml_section + "' section of configuration
file]";
- }
- logging::LOG_ERROR(logger_) << err_msg;
+ if (prop_pair.second.getValue().empty()) {
+ std::string reason("required property '");
--- End diff --
Why not use a string stream here?
---