Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0EEDD2009DC for ; Tue, 2 May 2017 19:28:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0D8E8160BAB; Tue, 2 May 2017 17:28:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 53F03160BBE for ; Tue, 2 May 2017 19:28:09 +0200 (CEST) Received: (qmail 32719 invoked by uid 500); 2 May 2017 17:28:08 -0000 Mailing-List: contact commits-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list commits@nifi.apache.org Received: (qmail 32710 invoked by uid 99); 2 May 2017 17:28:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 May 2017 17:28:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1AAB4C88EC for ; Tue, 2 May 2017 17:28:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.001 X-Spam-Level: X-Spam-Status: No, score=-100.001 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id qNwdyl2U7Htd for ; Tue, 2 May 2017 17:28:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 6DC605F3BB for ; Tue, 2 May 2017 17:28:06 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id C4ABFE01A8 for ; Tue, 2 May 2017 17:28:05 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 36B3A21DEA for ; Tue, 2 May 2017 17:28:05 +0000 (UTC) Date: Tue, 2 May 2017 17:28:05 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: commits@nifi.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (MINIFI-275) Configuration without IDs for components causes exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 02 May 2017 17:28:10 -0000 [ https://issues.apache.org/jira/browse/MINIFI-275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15993326#comment-15993326 ] ASF GitHub Bot commented on MINIFI-275: --------------------------------------- Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/85#discussion_r114375962 --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp --- @@ -538,14 +561,62 @@ void YamlConfiguration::parsePropertiesNodeYaml( std::string rawValueString = propertyValueNode.as(); if (!processor->setProperty(propertyName, rawValueString)) { logger_->log_warn( - "Received property %s with value %s but is not one of the properties for %s", - propertyName.c_str(), rawValueString.c_str(), - processor->getName().c_str()); + "Received property %s with value %s but it is not one of the properties for %s", + propertyName, + rawValueString, + processor->getName()); } } } } +std::string YamlConfiguration::getOrGenerateId( + YAML::Node *yamlNode, + std::string idField) { + std::string id; + YAML::Node node = yamlNode->as(); + + if (node[idField]) { + if (YAML::NodeType::Scalar == node[idField].Type()) { + id = node[idField].as(); + } else { + throw std::invalid_argument( + "getOrGenerateId: idField is expected to reference YAML::Node " + "of YAML::NodeType::Scalar."); + } + } else { + uuid_t uuid; + uuid_generate(uuid); + char uuid_str[37]; + uuid_unparse(uuid, uuid_str); + id = uuid_str; + logger_->log_debug("Generating random ID: id => [%s]", id); + } + return id; +} + +void YamlConfiguration::checkRequiredField( --- End diff -- Sorry, the double reply was likely confusing. I'm good with the function itself. The code that I'm looking at in our third party directory returns a Node template const Node operator[](const Key& key) const; The exception I reference is below and throws an InvalidNode if the node is invalid some how. Is this also handled? `template inline const Node Node::operator[](const Key& key) const { if (!m_isValid) throw InvalidNode(); EnsureNodeExists(); detail::node* value = static_cast(*m_pNode) .get(detail::to_value(key), m_pMemory); if (!value) { return Node(ZombieNode); } return Node(*value, m_pMemory); }` > Configuration without IDs for components causes exceptions > ---------------------------------------------------------- > > Key: MINIFI-275 > URL: https://issues.apache.org/jira/browse/MINIFI-275 > Project: Apache NiFi MiNiFi > Issue Type: Bug > Components: C++, Processing Configuration > Reporter: Aldrin Piri > Assignee: Kevin Doran > Priority: Blocker > Fix For: cpp-0.2.0 > > Attachments: config.TEST.yml > > > One of the changes to how components are handled in C++ introduced a defect into the original construct over the version 1 schema of the YAML. > The absence of this ID causes a YAML exception. > We should provide handling to support configurations how they were created originally, possibly providing a default/generated ID where one isn't specified, and start laying the foundation for versioned schemas as provided in our Java implementation. -- This message was sent by Atlassian JIRA (v6.3.15#6346)