Skip to content

custom operation handlers fail with unclear reason when tmp.path does not exist #3796

@reubenmiller

Description

@reubenmiller

Describe the bug

When using a custom operation handler, if the tmp.path directory does not exist, then the operation fails with a "No such file or directory" error, however it is unclear to the user that the problem is with the tmp.path and not with the operation executable itself.

tedge-mapper-c8y-1  | 2025-09-24T08:43:53.490703303Z ERROR c8y_mapper_ext::converter: Operation execution failed: No such file or directory (os error 2). Command: /usr/bin/c8y-command. Operation name: c8y_Command

The root cause if because when the tedge-mapper creates a process to execute the command, it sets the process's working directory to the tmp.path directory as shown in the code below:

LoggedCommand::new(command, self.config.tmp_dir.as_ref()).map_err(|e| {
CumulocityMapperError::ExecuteFailed {
error_message: e.to_string(),
command: command.to_string(),
operation_name: operation_name.to_string(),
}
})?;

This was found whilst building a container image which didn't have a /tmp directory, but it was very difficult to diagnose that the missing /tmp was the root cause for the failing operation as there was no indication that the temp folder was being used.

To Reproduce

  1. Create a custom operation handler

    File: /etc/tedge/operations/c8y/c8y_Command

    [exec]
    topic = "c8y/s/ds"
    on_message = "511"
    command = "/usr/bin/c8y-command"
  2. Create a dummy script and make it executable

    cat <<EOT | sudo tee -a /usr/bin/c8y-command
    #!/bin/sh
    exit 0
    EOT
    sudo chmod +x /usr/bin/c8y-command
  3. Set the tmp.path to a path that does not exist and restart the mapper

    sudo tedge config set tmp.path /dummy
    sudo tedge reconnect c8y
  4. Send an c8y_Command operation to the device and observe that the operation is set to failed, and the tedge-mapper-c8y shows the "No such file or directory" error in its log

Expected behavior

There are a few options that could potentially address this.

  • Option 1: Explicitly check that the tmp.path exists before executing the command and create a new error message

  • Option 2: Avoid setting the tmp.path when running the process (or skip the setting it if it does not exist)

Screenshots

Environment (please complete the following information):

  • OS [incl. version]: any
  • Hardware [incl. revision]: any
  • System-Architecture [e.g. result of "uname -a"]: any
  • thin-edge.io version [e.g. 0.1.0]: 1.6.1

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtheme:c8yTheme: Cumulocity related topics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions