Repository navigation
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
Thesession.read(...)I/O failure path (io::isError(read)) returnsIoResult::error()but does… · New When the namespace-index property evaluates to an empty string (missing property or expression… · Newunistd.handaccess()make this test server implementation POSIX-specific and can break builds… · Newunistd.handaccess()make this test server implementation POSIX-specific and can break builds… · New
What changed in this PR
Adds OPC UA file upload support by introducing the new PutOPCFile processor and extending the existing OPC UA file transfer/test infrastructure to support writing, file creation, and improved browse/path resolution.
Changes:
- Introduces
PutOPCFileprocessor (overwrite/append, optional create-under-parent behavior) and documents it. - Extends OPC UA file transfer support (
RemoteFile::write,CreateFilesupport) and improves browse/path resolution helpers. - Expands test coverage: new
PutOPCFileunit tests, updated integration feature scenarios, and enhanced test servers.
| File | Description |
|---|---|
| extensions/opc/src/PutOPCFile.cpp | Implements the new PutOPCFile processor logic (resolve/create target file, write via OPC UA file methods). |
| extensions/opc/include/PutOPCFile.h | Declares processor properties/relationships/output attributes for PutOPCFile. |
| extensions/opc/tests/PutOPCFileTests.cpp | Adds comprehensive unit tests for PutOPCFile behavior (overwrite/append/create/error cases). |
| extensions/opc/src/OPCFileTransfer.cpp | Adds RemoteFile write support and CreateFile invocation helper; centralizes chunk sizing. |
| extensions/opc/include/OPCFileTransfer.h | Extends RemoteFile API with write() and adds createFileInDirectory() declaration. |
| extensions/opc/src/OPCCommon.cpp | Adds browse-with-pagination helper (findObjectChildByName) and renames child lookup to qualified-name variant. |
| extensions/opc/include/OPCCommon.h | Exposes new/renamed client browse helper APIs. |
| extensions/opc/src/BaseOPCProcessor.cpp | Centralizes path resolution and “target node” resolution logic for reuse across processors. |
| extensions/opc/include/BaseOPCProcessor.h | Adds shared resolvePathNode()/resolveTargetNode() helpers and supporting structs. |
| extensions/opc/src/FetchOPCFile.cpp | Refactors to use shared path resolution and new RemoteFile chunk sizing API. |
| extensions/opc/include/FetchOPCFile.h | Updates cached file state to align with RemoteFile-managed chunk sizing. |
| extensions/opc/src/PutOPCProcessor.cpp | Refactors target-node resolution to use new BaseOPCProcessor helper and updates logging. |
| extensions/opc/include/PutOPCProcessor.h | Removes now-redundant private resolution helpers (moved to BaseOPCProcessor). |
| extensions/opc/src/FetchOPCHistory.cpp | Refactors to use shared path resolution and updated error logging. |
| extensions/opc/src/FetchOPCEvents.cpp | Refactors to use shared path resolution and updated error logging. |
| extensions/opc/tests/PutOPCProcessorTests.cpp | Updates assertions to match revised/standardized error messages. |
| extensions/opc/tests/FetchOPCFileTests.cpp | Updates assertion to match revised file-node path resolution error message. |
| extensions/opc/tests/FetchOPCEventsTests.cpp | Updates assertions to match revised path translation/multi-node error messages. |
| extensions/opc/tests/OpcUaTestServer.h | Extends test server with FileType Write support, CreateFile support, paging controls, and file content accessors. |
| extensions/opc/tests/features/opcua_file_transfer.feature | Adds BDD scenarios for creating/overwriting/appending files via PutOPCFile. |
| extensions/opc/tests/features/steps/steps.py | Adds new step to assert file server file content within a timeout. |
| extensions/opc/tests/features/containers/opc_ua_file_server_container.py | Adds helper to validate server-side file content. |
| extensions/opc/tests/features/resources/opcua-file-server/file_server.cpp | Extends OPC UA file server for writable files and CreateFile/Write methods. |
| PROCESSORS.md | Documents PutOPCFile properties/relationships/output attributes. |
| .github/references/docker_manifest.json | Registers PutOPCFile in the processor manifest for tooling/docs. |
Review effort: Lite
szaszm
left a comment
There was a problem hiding this comment.
It would be nice if we could use RAII wrappers for all OPC-UA library types. During a manual review, I didn't spot any leaks, but having the compiler prove it would be more reassuring. On the other hand, the RAII wrapper types may introduce a lot of boilerplate, so it's up to you if you think it's worth it.
| if (std::filesystem::exists(path, error)) { | ||
| return UA_STATUSCODE_BADBROWSENAMEDUPLICATED; | ||
| } | ||
| if (!std::ofstream(path, std::ios::binary)) { |
There was a problem hiding this comment.
I'd change this to clarify the meaning. {} makes it clear that this is indended to be a temporary object, not a function call, and the comment further clarifies the purpose.
| if (!std::ofstream(path, std::ios::binary)) { | |
| // create empty file | |
| if (!std::ofstream{path, std::ios::binary}) { |
| UA_NODEID_NUMERIC(0, UA_NS0ID_FILEDIRECTORYTYPE), | ||
| attr, | ||
| nullptr, | ||
| const_cast<std::filesystem::path*>(&data_dir), |
There was a problem hiding this comment.
Could you add a comment explaining why this const_cast is safe in practice?
| std::swap(continuation_point, result.continuationPoint); | ||
| for (size_t i = 0; i < result.referencesSize; ++i) { | ||
| const auto& ref = result.references[i]; | ||
| if (std::string_view(reinterpret_cast<const char*>(ref.browseName.name.data), ref.browseName.name.length) == browse_name) { |
There was a problem hiding this comment.
I'd extract ref.browseName.name too, with a type if possible, to make future changes less error-prone. (the two long distance references shouldn't be able to drift from each other)
| const auto guard = gsl::finally([&browse_request, &browse_response]() { | ||
| UA_BrowseRequest_clear(&browse_request); | ||
| UA_BrowseResponse_clear(&browse_response); | ||
| }); |
There was a problem hiding this comment.
Should we separate the two cleanup guards, to avoid possible future cases where an error between the two initializations cause the resources of one to be leaked?
3b6ce15 to
2c6614b
Compare
6220a61 to
9346f9d
Compare
I think it's a good idea and worth the the effort, we can investigate how much boilerplate would it add, but if it's manageable it's worth implementing. I would handle this improvement separately, so I added a jira ticket for this: https://issues.apache.org/jira/browse/MINIFICPP-2950 |
2c6614b to
34c6c98
Compare
9346f9d to
c504f6a
Compare
34c6c98 to
e3f5cb8
Compare
c504f6a to
f4e687b
Compare


https://issues.apache.org/jira/browse/MINIFICPP-2928
Depends on #2287
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:
For documentation related changes:
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.