MINIFICPP-2869 Improve rust api property validation and property getters - #2220
MINIFICPP-2869 Improve rust api property validation and property getters#2220martinzink wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the Rust-side MiNiFi property API to support typed property getters with centralized constraint validation, and updates the example playground processors/controller services to use the new API. It also extends error handling and adds some small quality-of-life improvements (Relationship Display, test helper utilities).
Changes:
- Introduce
PropertyConstraints+PropertyTypeand replace ad-hoc typed getters with genericget_property<T>()/get_req_property<T>(). - Update C-FFI property registration and playground processors/controller services to the new constraints/getter model.
- Add new error variants/conversions and minor utilities/macros for transforms and logging/property types.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| minifi_rust/minifi_rs_behave/src/main.rs | Installs an additional Python dependency (certifi) for behave runner setup. |
| minifi_rust/minifi_native/src/mock/mock_controller_service_context.rs | Updates mock context to implement the renamed raw property getter (get_raw_property). |
| minifi_rust/minifi_native/src/lib.rs | Re-exports new property API types and adds extern crate self as minifi_native to support macro paths. |
| minifi_rust/minifi_native/src/c_ffi/c_ffi_property.rs | Adapts C-FFI property definition generation to PropertyConstraints. |
| minifi_rust/minifi_native/src/c_ffi/c_ffi_controller_service_context.rs | Renames trait method impl to get_raw_property. |
| minifi_rust/minifi_native/src/api/relationship.rs | Adds Display impl for Relationship. |
| minifi_rust/minifi_native/src/api/property.rs | Introduces PropertyConstraints, PropertyType, and typed getters (get_property<T>, get_req_property<T>). |
| minifi_rust/minifi_native/src/api/processor_wrappers/utils/context_session_flowfile_bundle.rs | Updates GetProperty impl to get_raw_property. |
| minifi_rust/minifi_native/src/api/processor_wrappers/flow_file_transform.rs | Adds test-utils byte extraction and introduces unwrap_or_route! helper macro. |
| minifi_rust/minifi_native/src/api/process_context.rs | Removes legacy typed getters from ProcessContext and updates GetProperty impl to get_raw_property. |
| minifi_rust/minifi_native/src/api/logger.rs | Adds derived PropertyType for LogLevel and updates strum derives. |
| minifi_rust/minifi_native/src/api/errors.rs | Adds attribute-missing error + float/infallible conversions and implements std::error::Error. |
| minifi_rust/minifi_native/src/api/attribute.rs | Adds get_required_attribute helper built on the new attribute-missing error. |
| minifi_rust/minifi_native/src/api.rs | Re-exports new property API surface (DataSize, PropertyConstraints, PropertyType). |
| minifi_rust/minifi_native/Cargo.toml | Adds test-utils feature for conditional helpers. |
| minifi_rust/minifi_native_macros/src/lib.rs | Adds #[derive(PropertyType)] proc-macro to auto-wire allowed-values parsing/constraints. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/zoo_processor.rs | Migrates controller-service property constraints to AllowedType. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/put_file/unix_only_properties.rs | Migrates unix-only properties to NoConstraints. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/put_file/properties.rs | Migrates PutFile properties to Validator/AllowedValues constraints. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/put_file.rs | Switches PutFile implementation to typed get_property<T> / get_req_property<T>. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/lorem_ipsum_cs_user/properties.rs | Migrates properties to AllowedType/AllowedValues. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/lorem_ipsum_cs_user.rs | Switches to typed get_req_property<T> for enum property. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/log_attribute/properties.rs | Migrates LogAttribute properties to new constraints and improves enum default handling. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/log_attribute.rs | Switches LogAttribute scheduling/parsing to typed property getters. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/kamikaze_processor/properties.rs | Migrates Kamikaze properties to AllowedValues/NoConstraints. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/kamikaze_processor.rs | Switches Kamikaze processor to typed getters for enum/string properties. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/get_file/properties.rs | Migrates GetFile properties to Validator constraints and adjusts required flags for typed required getters. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/get_file.rs | Switches GetFile scheduling to typed getters including DataSize/Duration. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/generate_flow_file/properties.rs | Migrates GenerateFlowFile properties to Validator/AllowedValues/NoConstraints. |
| minifi_rust/extensions/minifi_rs_playground/src/processors/generate_flow_file.rs | Switches GenerateFlowFile scheduling to typed getters including DataSize. |
| minifi_rust/extensions/minifi_rs_playground/src/controller_services/lorem_ipsum_controller_service.rs | Migrates property constraints and switches to typed required getter. |
| minifi_rust/extensions/minifi_rs_playground/src/controller_services/dog_controller_service.rs | Migrates property constraints and switches to typed getters for bool/string. |
| minifi_rust/extensions/minifi_rs_playground/Cargo.toml | Minor formatting-only change (blank line). |
Comments suppressed due to low confidence (5)
minifi_rust/minifi_native/src/c_ffi/c_ffi_property.rs:96
- This
match p.constraintsmovesconstraintsout of&Property(notCopy), which will not compile. Match on a reference instead.
.iter()
.map(|p| match p.constraints {
PropertyConstraints::AllowedType(allowed_type) => allowed_type.as_minifi_c_type(),
minifi_rust/minifi_native/src/api/processor_wrappers/flow_file_transform.rs:236
- This exported macro should not hardcode the crate name (
minifi_native::...) because it breaks if the dependency is renamed. Use$crate::error!so the path is stable.
minifi_native::error!(
$custom_logger,
"Failed to unwrap due to {}. Routing flow file.",
e
);
minifi_rust/minifi_native/src/api/processor_wrappers/flow_file_transform.rs:237
TransformedFlowFileis referenced unqualified inside this exported macro, forcing callers to import it. Use$crate::TransformedFlowFileto make the macro usable without additional imports.
return Ok(TransformedFlowFile::route_without_changes($route));
minifi_rust/minifi_native/src/api/processor_wrappers/flow_file_transform.rs:246
- This exported macro uses
error!unqualified, which resolves at the call site and may fail if the caller hasn't importederror!. Use$crate::error!for hygienic macro expansion.
error!(
minifi_rust/minifi_native/src/api/processor_wrappers/flow_file_transform.rs:250
TransformedFlowFileis referenced unqualified inside this exported macro, forcing callers to import it. Use$crate::TransformedFlowFileto make the macro usable without additional imports.
return Ok(TransformedFlowFile::route_without_changes($route));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fb60b49 to
8d10bf2
Compare
f71f4d2 to
e09d572
Compare
d1265b7 to
1219616
Compare
1219616 to
a313436
Compare
a313436 to
bbeede5
Compare
bbeede5 to
18547e8
Compare
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.