feat: Allow [input.process] to take a relative path for command#4176
Open
jarhodes314 wants to merge 2 commits into
Open
feat: Allow [input.process] to take a relative path for command#4176jarhodes314 wants to merge 2 commits into
[input.process] to take a relative path for command#4176jarhodes314 wants to merge 2 commits into
Conversation
Signed-off-by: James Rhodes <jarhodes314@gmail.com>
Signed-off-by: James Rhodes <jarhodes314@gmail.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Contributor
Robot Results
Failed Tests
|
didier-wenzek
requested changes
May 18, 2026
| futures = { workspace = true } | ||
| glob = { workspace = true } | ||
| humantime = { workspace = true } | ||
| path-clean = { workspace = true } |
Contributor
There was a problem hiding this comment.
Even if controlling dependencies seems to be a lost battle, I wonder. Wouldn't canonicalize be enough?
Contributor
Author
There was a problem hiding this comment.
Almost certainly, I didn't realise we already depended on two crates that do this same thing (path-clean is not a new dependency)
Comment on lines
+486
to
+489
| command: if Utf8Path::new(&command).is_relative() { | ||
| path_clean::clean(flows_dir.join(&command)) | ||
| .to_string_lossy() | ||
| .into_owned() |
Contributor
There was a problem hiding this comment.
Beware, the command is not a path but a command line possibly with arguments.
We to call first `shell_words::split().
We can also consider to:
- normalize not only the command path but any argument looking akin to a path.
- properly type
InputConfig::Process::commandas an array ofString.
Contributor
There was a problem hiding this comment.
For instance the following test is red:
#[test]
fn relative_process_paths_are_cleaned_up() {
let flow_toml = r#"
[input.process]
command = "./../flows/./my_flow/../test.sh foo /../bar"
interval = "1s"
"#;
let flow: FlowConfig = toml::from_str(flow_toml).unwrap();
let resolved = flow
.input
.resolve_relative_process_paths(Utf8Path::new("/flows"));
assert_eq!(
resolved,
InputConfig::Process {
topic: None,
command: "/flows/test.sh foo /../bar".into(),
interval: Some(IntervalConfig::Duration(Duration::from_secs(1))),
}
)
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Allow users to specify a relative path for the
commandin an[input.process], enabling people to ship the input script as part of the flow itself.Types of changes
Paste Link to the issue
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments