Skip to content

feat: Allow [input.process] to take a relative path for command#4176

Open
jarhodes314 wants to merge 2 commits into
thin-edge:mainfrom
jarhodes314:feat/flow-relative-input-process-path
Open

feat: Allow [input.process] to take a relative path for command#4176
jarhodes314 wants to merge 2 commits into
thin-edge:mainfrom
jarhodes314:feat/flow-relative-input-process-path

Conversation

@jarhodes314
Copy link
Copy Markdown
Contributor

Proposed changes

Allow users to specify a relative path for the command in an [input.process], enabling people to ship the input script as part of the flow itself.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Signed-off-by: James Rhodes <jarhodes314@gmail.com>
Signed-off-by: James Rhodes <jarhodes314@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 98.30508% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/extensions/tedge_flows/src/config.rs 98.30% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
911 2 4 913 99.78 2h49m37.034058999s

Failed Tests

Name Message ⏱️ Duration Suite
Consuming messages from a process stdout Matching messages on topic 'log/journalctl-follow' is less than minimum. wanted: 10 got: 0 messages: [] [RETRY] FAIL on 3. retry. 32.388 s Tedge Flows
Consuming messages from a process stdout, periodically Matching messages on topic 'log/journalctl-cursor' is less than minimum. wanted: 1 got: 0 messages: [] [RETRY] FAIL on 3. retry. 30.736 s Tedge Flows

Copy link
Copy Markdown
Contributor

@albinsuresh albinsuresh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

futures = { workspace = true }
glob = { workspace = true }
humantime = { workspace = true }
path-clean = { workspace = true }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if controlling dependencies seems to be a lost battle, I wonder. Wouldn't canonicalize be enough?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::command as an array of String.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))),
            }
        )
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants