[GH-ISSUE #597] [Bug] Action: onFinish exit code is always 0, even when command exits with non-zero code #5020

Closed
opened 2026-04-22 00:12:28 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @adriankirchner on GitHub (Jun 10, 2025).
Original GitHub issue: https://github.com/moghtech/komodo/issues/597

The onFinish callback of komodo.execute_terminal always receives code = 0, regardless of the actual exit code of the executed command.

Example

$ docker run --rm alpine sh -c "exit 1"
$ echo $?
1

Action code

// Run actions using the pre initialized 'komodo' client.
const version: Types.GetVersionResponse = await komodo.read('GetVersion', {});
console.log('🦎 Komodo version:', version.version, '🦎\n');

const stacks = await komodo.read("ListStacks", {
  query: { tags: ["pgsql-backup"] },
});

for (const stack of stacks) {
  const stackName = stack.name;
  const server = (stack as any).info.server_id as string;

  console.log(`→ Running on stack ${stackName} on server ${server}`);

  await komodo.write("CreateTerminal", {
    server,
    name: `test-${stackName}`,
    command: "bash",
    recreate: Types.TerminalRecreateMode.DifferentCommand,
  });

  // Build & run the mysqldump command
  const dumpCmd = [
    `docker run --rm alpine sh -c "exit 1"`
  ].join(" && ");

  console.log(dumpCmd);

  await komodo.execute_terminal(
    {
      server,
      terminal: `test-${stackName}`,
      command: dumpCmd,
    },
    {
      onLine: console.log,
      onFinish: (code) => {
      console.log("Finished:", code);
        if (parseInt(code) !== 0) {
          throw new Error(`Command failed with exit code ${code}`);
        }
      },
    }
  );
}

Output

🦎 Komodo version: 1.18.1 🦎

→ Running on stack test-stack on server 68229594cd4d7c59270e550f
docker run --rm alpine sh -c "exit 1"


Finished: 0
🦎 Action completed successfully 🦎

Expected Behavior

onFinish should be called with the actual exit code of the command executed in the terminal (in this example: 1).

Actual Behavior

onFinish is always called with code = 0, even when the command fails with a non-zero exit code.

Impact

Error handling in automation or scripts relying on komodo.execute_terminal is currently not possible, since all commands appear to succeed.

Environment:

  • Komodo 1.18.1
  • Running via docker on Ubuntu 24.04
Originally created by @adriankirchner on GitHub (Jun 10, 2025). Original GitHub issue: https://github.com/moghtech/komodo/issues/597 The onFinish callback of komodo.execute_terminal always receives code = 0, regardless of the actual exit code of the executed command. **Example** ```sh $ docker run --rm alpine sh -c "exit 1" $ echo $? 1 ``` **Action code** ```js // Run actions using the pre initialized 'komodo' client. const version: Types.GetVersionResponse = await komodo.read('GetVersion', {}); console.log('🦎 Komodo version:', version.version, '🦎\n'); const stacks = await komodo.read("ListStacks", { query: { tags: ["pgsql-backup"] }, }); for (const stack of stacks) { const stackName = stack.name; const server = (stack as any).info.server_id as string; console.log(`→ Running on stack ${stackName} on server ${server}`); await komodo.write("CreateTerminal", { server, name: `test-${stackName}`, command: "bash", recreate: Types.TerminalRecreateMode.DifferentCommand, }); // Build & run the mysqldump command const dumpCmd = [ `docker run --rm alpine sh -c "exit 1"` ].join(" && "); console.log(dumpCmd); await komodo.execute_terminal( { server, terminal: `test-${stackName}`, command: dumpCmd, }, { onLine: console.log, onFinish: (code) => { console.log("Finished:", code); if (parseInt(code) !== 0) { throw new Error(`Command failed with exit code ${code}`); } }, } ); } ``` **Output** ``` 🦎 Komodo version: 1.18.1 🦎 → Running on stack test-stack on server 68229594cd4d7c59270e550f docker run --rm alpine sh -c "exit 1" Finished: 0 🦎 Action completed successfully 🦎 ``` **Expected Behavior** onFinish should be called with the actual exit code of the command executed in the terminal (in this example: 1). **Actual Behavior** onFinish is always called with code = 0, even when the command fails with a non-zero exit code. **Impact** Error handling in automation or scripts relying on komodo.execute_terminal is currently not possible, since all commands appear to succeed. **Environment:** - Komodo 1.18.1 - Running via docker on Ubuntu 24.04
GiteaMirror added the bug label 2026-04-22 00:12:28 -05:00
Author
Owner

@ndejong commented on GitHub (Jul 27, 2025):

Worth a note - getting this resolved looks like it would have an impact on https://github.com/moghtech/komodo/issues/538 that is a feature-request to support one-shot / exiting containers too.

<!-- gh-comment-id:3124453013 --> @ndejong commented on GitHub (Jul 27, 2025): Worth a note - getting this resolved looks like it would have an impact on https://github.com/moghtech/komodo/issues/538 that is a feature-request to support one-shot / exiting containers too.
Author
Owner

@mbecker20 commented on GitHub (Aug 28, 2025):

Linked commit should fix. Will be included in 1.19.2
Image

<!-- gh-comment-id:3232668472 --> @mbecker20 commented on GitHub (Aug 28, 2025): Linked commit should fix. Will be included in 1.19.2 <img width="506" height="657" alt="Image" src="https://github.com/user-attachments/assets/7007785b-3a14-4527-88e2-5cd79b5f9982" />
Author
Owner

@adriankirchner commented on GitHub (Sep 1, 2025):

The issue is fixed in 1.19.2

<!-- gh-comment-id:3242800115 --> @adriankirchner commented on GitHub (Sep 1, 2025): The issue is fixed in 1.19.2
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/komodo#5020