You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "lordgamez (via GitHub)" <gi...@apache.org> on 2026/09/18 15:01:49 UTC
[PR] MINIFICPP-2906 Add guid nodeid support for OPC processors [nifi-minifi-cpp]
lordgamez opened a new pull request, #2266:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2266
- Make Parent node ID property optional for PutOPCProcessor
- Move node id parsing to onSchedule where possible
- Add missing tests for uncovered use cases like multiple node id types
- Additional refactoring of common code
https://issues.apache.org/jira/browse/MINIFICPP-2906
---------------------
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?
- [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file?
- [ ] If applicable, have you updated the NOTICE file?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2906 Add guid nodeid support for OPC processors [nifi-minifi-cpp]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2266:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2266#discussion_r4047969661
##########
extensions/opc/src/PutOPCProcessor.cpp:
##########
@@ -281,9 +246,21 @@ void PutOPCProcessor::onTrigger(core::ProcessContext& context, core::ProcessSess
return;
}
- if (!readParentNodeId()) {
- context.yield();
- return;
+ if (parent_node_defined_ && id_type_ == opc::OPCNodeIDType::Path && !path_node_id_resolved_) {
+ std::vector<opc::NodeId> translated_node_ids;
+ auto sc = connection_->translateBrowsePathsToNodeIdsRequest(node_id_, translated_node_ids, namespace_idx_, path_reference_types_, logger_);
+ if (sc != UA_STATUSCODE_GOOD) {
+ logger_->log_error("Failed to translate path '{}' to a node id: {}", node_id_, UA_StatusCode_name(sc));
+ context.yield();
+ return;
+ }
+ if (translated_node_ids.size() != 1) {
+ logger_->log_error("Path '{}' resolved to {} node ids; exactly one target node is required for put", node_id_, translated_node_ids.size());
+ context.yield();
+ return;
+ }
+ node_ = std::move(translated_node_ids[0]);
+ path_node_id_resolved_ = true;
}
Review Comment:
This permanently caches the parent path translation, although `reconnect()` never invalidates `path_node_id_resolved_`. If the OPC server restarts or the path is deleted and recreated with a different server-assigned NodeId, subsequent creates continue using the stale parent; the previous implementation resolved the path on every trigger. Resolve this path per trigger, or invalidate the cached NodeId whenever the connection is re-established.
##########
extensions/opc/src/OPCCommon.cpp:
##########
@@ -584,4 +593,27 @@ UA_StatusCode Client::readHistory(HistoryReadTypeOption history_type, const UA_N
return UA_Client_HistoryRead_raw(client_, &node_id, callback, start_time, end_time, UA_STRING_NULL, false, 0, UA_TIMESTAMPSTORETURN_SOURCE, callback_context);
}
+std::expected<opc::NodeId, std::string> buildNodeId(opc::OPCNodeIDType id_type, UA_UInt16 namespace_idx, const std::string& node_id) {
+ switch (id_type) {
+ case opc::OPCNodeIDType::String:
+ return opc::NodeId{UA_NODEID_STRING_ALLOC(namespace_idx, node_id.c_str())};
+ case opc::OPCNodeIDType::Int:
+ try {
+ return opc::NodeId{UA_NODEID_NUMERIC(namespace_idx, std::stoi(node_id))};
+ } catch(const std::exception&) {
+ auto error_msg = utils::string::join_pack(node_id, " cannot be used as an int type node ID");
+ return std::unexpected{error_msg};
+ }
Review Comment:
Numeric OPC NodeIds are `UA_UInt32`, but `std::stoi` parses only the signed `int` range and its negative result is then converted to unsigned. Consequently, a valid ID such as `4294967295` is rejected while `-1` silently addresses that same ID; trailing text such as `666junk` is also accepted. Parse the complete input into the unsigned 32-bit range before constructing the NodeId.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2906 Add guid nodeid support for OPC processors [nifi-minifi-cpp]
Posted by "lordgamez (via GitHub)" <gi...@apache.org>.
lordgamez commented on code in PR #2266:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2266#discussion_r4060527293
##########
extensions/opc/src/PutOPCProcessor.cpp:
##########
@@ -281,9 +246,21 @@ void PutOPCProcessor::onTrigger(core::ProcessContext& context, core::ProcessSess
return;
}
- if (!readParentNodeId()) {
- context.yield();
- return;
+ if (parent_node_defined_ && id_type_ == opc::OPCNodeIDType::Path && !path_node_id_resolved_) {
+ std::vector<opc::NodeId> translated_node_ids;
+ auto sc = connection_->translateBrowsePathsToNodeIdsRequest(node_id_, translated_node_ids, namespace_idx_, path_reference_types_, logger_);
+ if (sc != UA_STATUSCODE_GOOD) {
+ logger_->log_error("Failed to translate path '{}' to a node id: {}", node_id_, UA_StatusCode_name(sc));
+ context.yield();
+ return;
+ }
+ if (translated_node_ids.size() != 1) {
+ logger_->log_error("Path '{}' resolved to {} node ids; exactly one target node is required for put", node_id_, translated_node_ids.size());
+ context.yield();
+ return;
+ }
+ node_ = std::move(translated_node_ids[0]);
+ path_node_id_resolved_ = true;
}
Review Comment:
Good catch, fixed in https://github.com/apache/nifi-minifi-cpp/pull/2266/commits/dd59350fb38d9a9e82ae25add0aa8b14a6f9982d
##########
extensions/opc/src/OPCCommon.cpp:
##########
@@ -584,4 +593,27 @@ UA_StatusCode Client::readHistory(HistoryReadTypeOption history_type, const UA_N
return UA_Client_HistoryRead_raw(client_, &node_id, callback, start_time, end_time, UA_STRING_NULL, false, 0, UA_TIMESTAMPSTORETURN_SOURCE, callback_context);
}
+std::expected<opc::NodeId, std::string> buildNodeId(opc::OPCNodeIDType id_type, UA_UInt16 namespace_idx, const std::string& node_id) {
+ switch (id_type) {
+ case opc::OPCNodeIDType::String:
+ return opc::NodeId{UA_NODEID_STRING_ALLOC(namespace_idx, node_id.c_str())};
+ case opc::OPCNodeIDType::Int:
+ try {
+ return opc::NodeId{UA_NODEID_NUMERIC(namespace_idx, std::stoi(node_id))};
+ } catch(const std::exception&) {
+ auto error_msg = utils::string::join_pack(node_id, " cannot be used as an int type node ID");
+ return std::unexpected{error_msg};
+ }
Review Comment:
Good point, fixed in https://github.com/apache/nifi-minifi-cpp/pull/2266/commits/dd59350fb38d9a9e82ae25add0aa8b14a6f9982d
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org