-
Notifications
You must be signed in to change notification settings - Fork 69
Description
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_CommandThe 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:
thin-edge.io/crates/extensions/c8y_mapper_ext/src/converter.rs
Lines 1016 to 1022 in 6ba9d2e
| 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
-
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"
-
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
-
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 -
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.pathexists before executing the command and create a new error message -
Option 2: Avoid setting the
tmp.pathwhen 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