[GH-ISSUE #1289] [Bug] "execute_container_terminal" randomly fails to execute #6617

Open
opened 2026-04-24 19:43:25 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @bastienlc on GitHub (Mar 28, 2026).
Original GitHub issue: https://github.com/moghtech/komodo/issues/1289

Setting

komodo-core and komodo-periphery running 2.0.0 docker image

Assume a debian:bookworm container is running on "my-server":

docker run --name debug -it debian:bookworm /bin/sh

I'm trying to execute a command on this container using an Action, specifically the execute_container_terminal method of the typescript client. Thus from the UI I create an action with this content:

let shell = "sh"; // sh or bash
let server = "my-server";
let container = "debug";
let command = "date";

await komodo.execute_container_terminal(
  {
    server,
    container,
    command,
    init: { command: shell, recreate: "Always" },
  },
  {
    onLine: (line) => {
      console.log(line);
    },
    onFinish: (code) => {
      console.log(`Command finished with exit code ${code}`);
    },
  },
);

Expected behavior

Using bash or sh, executing the action succeeds and the following output is produced:


Sat Mar 28 20:31:22 UTC 2026

Command finished with exit code 0
🦎 Action completed successfully 🦎

Actual behavior

Sometimes the command is executed incorrectly, resulting in the following output:


'; date; rc=$?; printf '
Command finished with exit code %d
🦎 Action completed successfully 🦎

I have not been able to pinpoint exactly what causes this behavior to occur, currently it seems random.

Initial analysis

While I'm not familiar with the komodo source code, the issue seems to stem from this snippet:
0f96794559/bin/periphery/src/api/terminal.rs (L466-L468)

Edits

  • Updated behavior from "succeeds with bash but fails with sh" to "randomly fails"
Originally created by @bastienlc on GitHub (Mar 28, 2026). Original GitHub issue: https://github.com/moghtech/komodo/issues/1289 ## Setting *komodo-core and komodo-periphery running 2.0.0 docker image* Assume a debian:bookworm container is running on "my-server": ```bash docker run --name debug -it debian:bookworm /bin/sh ``` I'm trying to execute a command on this container using an Action, specifically the `execute_container_terminal` method of the typescript client. Thus from the UI I create an action with this content: ```ts let shell = "sh"; // sh or bash let server = "my-server"; let container = "debug"; let command = "date"; await komodo.execute_container_terminal( { server, container, command, init: { command: shell, recreate: "Always" }, }, { onLine: (line) => { console.log(line); }, onFinish: (code) => { console.log(`Command finished with exit code ${code}`); }, }, ); ``` ## Expected behavior Using `bash` or `sh`, executing the action succeeds and the following output is produced: ```bash Sat Mar 28 20:31:22 UTC 2026 Command finished with exit code 0 🦎 Action completed successfully 🦎 ``` ## Actual behavior Sometimes the command is executed incorrectly, resulting in the following output: ```bash '; date; rc=$?; printf ' Command finished with exit code %d 🦎 Action completed successfully 🦎 ``` I have not been able to pinpoint exactly what causes this behavior to occur, currently it seems random. ## Initial analysis While I'm not familiar with the komodo source code, the issue seems to stem from this snippet: https://github.com/moghtech/komodo/blob/0f9679455911ce9f078e1d3654437ce4cda84eda/bin/periphery/src/api/terminal.rs#L466-L468 ## Edits - Updated behavior from "succeeds with bash but fails with sh" to "randomly fails"
Author
Owner

@martkaczmarek commented on GitHub (Apr 14, 2026):

Happening to me too.
Komodo periphery + core both on Docker, 2.1.2

In my case, even multiple executes across a singe action could change behavior (this is output of a single action):

execute_stack_exec bash:

Tue Apr 14 19:07:41 UTC 2026       <--"date" command executed properly

Exit code: 0
execute_stack_exec sh:

'; date; rc=$?; printf '       <--"date" command printed as is
Exit code: %d
execute_stack_service_terminal bash:

'; date; rc=$?; printf '
Finished. Code:  %d
execute_stack_service_terminal sh:

'; date; rc=$?; printf '
Finished. Code:  %d
🦎 Action completed successfully 🦎

My testing was done on stacks (komodo.execute_stack_exec), but same result.

<!-- gh-comment-id:4246440732 --> @martkaczmarek commented on GitHub (Apr 14, 2026): Happening to me too. Komodo periphery + core both on Docker, 2.1.2 In my case, even multiple executes across a singe action could change behavior (this is output of a single action): ``` execute_stack_exec bash: Tue Apr 14 19:07:41 UTC 2026 <--"date" command executed properly Exit code: 0 execute_stack_exec sh: '; date; rc=$?; printf ' <--"date" command printed as is Exit code: %d execute_stack_service_terminal bash: '; date; rc=$?; printf ' Finished. Code: %d execute_stack_service_terminal sh: '; date; rc=$?; printf ' Finished. Code: %d 🦎 Action completed successfully 🦎 ``` My testing was done on stacks (komodo.execute_stack_exec), but same result.
Author
Owner

@martkaczmarek commented on GitHub (Apr 14, 2026):

I'd like to point out another thing:
even when output is wrong:

'; date; rc=$?; printf '
Exit code: %d
🦎 Action completed successfully 🦎

The terminal actually does execute the command and returns exit code:
Image
(this is the terminal executing the same action run)

It looks to me like Komodo is just confused as to which __KOMODO_START_OF_OUTPUT__ to treat as the actual output text - it catches the first one and returns '; date; rc=$?; printf ' which is below.

--Edit after a bit more testing:
In my case, the first run in a specific terminal will result in a wrong output. But if the terminal is not recreated, the subsequent commands return proper text.
@bastienlc can you confirm that? If you change recreate value to "Never" and not delete the terminal, the second and all subsequent runs should be fine.

<!-- gh-comment-id:4246626525 --> @martkaczmarek commented on GitHub (Apr 14, 2026): I'd like to point out another thing: even when output is wrong: ``` '; date; rc=$?; printf ' Exit code: %d 🦎 Action completed successfully 🦎 ``` The terminal actually does execute the command and returns exit code: <img width="472" height="494" alt="Image" src="https://github.com/user-attachments/assets/ed538918-96d6-489e-b1a6-1d054ac950b1" /> (this is the terminal executing the same action run) It looks to me like Komodo is just confused as to which `__KOMODO_START_OF_OUTPUT__` to treat as the actual output text - it catches the first one and returns `'; date; rc=$?; printf '` which is below. --Edit after a bit more testing: In my case, the first run in a specific terminal will result in a wrong output. But if the terminal is **not** recreated, the subsequent commands return proper text. @bastienlc can you confirm that? If you change recreate value to "Never" and not delete the terminal, the second and all subsequent runs should be fine.
Author
Owner

@mbecker20 commented on GitHub (Apr 14, 2026):

I think it should usually work if the shell is "bash", but doesn't seem to with "sh"

<!-- gh-comment-id:4247801911 --> @mbecker20 commented on GitHub (Apr 14, 2026): I think it should usually work if the shell is "bash", but doesn't seem to with "sh"
Author
Owner

@bastienlc commented on GitHub (Apr 15, 2026):

@martkaczmarek I have not been able to reproduce your results:

On debian/ubuntu images

  • Using bash, execute_container_terminal works on the first try, and also on subsequent tries when setting recreate: "Never"
  • Using sh, execute_container_terminal never works, not on the first try, and not on subsequent tries when setting recreate: "Never"

On alpine images

  • Using bash is not an option
  • Using sh, execute_container_terminal works on the first try, and also on subsequent tries when setting recreate: "Never"

Analysis

What I'm observing today corresponds to my initial assessment "succeeds with bash but fails with sh" on debian images. However I believe there is more to this issue, as I am seeing occasional failures with the same output when using bash:

  • In <1% of cases on an amd64 server
  • In a very significant number of cases on an arm64 server, with an unpredictable pattern (each X is a faillure on an action that runs every 5 minutes):
    OOOOXOXOOXXOOOOOXXOOOXOXOOXOXOOXOOOOOXOOOOXOOOOXXOXOXOOOXOOOXXOXOXXXXOXXXXXXXXOXOOXXOOOOOOOOOOOOOOO
    

But I'm unable to consistently reproduce these failures.

However I agree that this is a parsing issue of the terminal output, and the command is executed correctly. It still breaks functionality e.g. when using actions in procedures, the action errors out and the procedure fails.

<!-- gh-comment-id:4255287237 --> @bastienlc commented on GitHub (Apr 15, 2026): @martkaczmarek I have not been able to reproduce your results: #### On debian/ubuntu images - Using bash, `execute_container_terminal` works on the first try, and also on subsequent tries when setting `recreate: "Never"` - Using sh, `execute_container_terminal` never works, not on the first try, and not on subsequent tries when setting `recreate: "Never"` #### On alpine images - Using bash is not an option - Using sh, `execute_container_terminal` works on the first try, and also on subsequent tries when setting `recreate: "Never"` ### Analysis What I'm observing today corresponds to my initial assessment "succeeds with bash but fails with sh" on debian images. However I believe there is more to this issue, as I am seeing occasional failures with the same output when using bash: - In <1% of cases on an amd64 server - In a very significant number of cases on an arm64 server, with an unpredictable pattern (each X is a faillure on an action that runs every 5 minutes): ``` OOOOXOXOOXXOOOOOXXOOOXOXOOXOXOOXOOOOOXOOOOXOOOOXXOXOXOOOXOOOXXOXOXXXXOXXXXXXXXOXOOXXOOOOOOOOOOOOOOO ``` But I'm unable to consistently reproduce these failures. However I agree that this is a parsing issue of the terminal output, and the command is executed correctly. It still breaks functionality e.g. when using actions in procedures, the action errors out and the procedure fails.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/komodo#6617