You are viewing the docs for v1.3, which is not the latest release.
View latest

Script Tasks No Longer Enter WARNING State When ERROR Logs Are Present

For the complete documentation index, see llms.txt. For a full content snapshot, see llms-full.txt. Append .md to any kestra.io/docs/* URL for plain Markdown.

No more WARNING state on script tasks when ERROR logs are present

The task-run state is no longer set to Warning if the script task emits ERROR or WARNING logs, and the warningOnStdErr property is deprecated. Script tasks now always report a SUCCESS state if the Docker container exits with code 0, and a FAILED state for any non-zero exit code — ERROR or WARNING logs no longer influence the task run state.

Example flow:

yamlid: loguru
namespace: company.team

inputs:
  - id: nr_logs
    type: INT
    defaults: 100

tasks:
  - id: reproducer
    type: io.kestra.plugin.scripts.python.Script
    taskRunner:
      type: io.kestra.plugin.scripts.runner.docker.Docker
    containerImage: ghcr.io/kestra-io/pydata:latest
    script: |
      from loguru import logger
      from faker import Faker
      import time
      import sys

      logger.remove()
      logger.add(sys.stdout, level="DEBUG")
      logger.add(sys.stderr, level="DEBUG")

      def generate_logs(fake, num_logs):
          logger.error("Starting to generate log messages")
          for _ in range(num_logs):
              log_message = fake.sentence()
              logger.warning(log_message)
              time.sleep(0.01)
          logger.warning("Finished generating log messages")

      if __name__ == "__main__":
          faker_ = Faker()
          generate_logs(faker_, int("{{ inputs.nr_logs }}"))

Before this change, the flow would end in WARNING; now it ends in SUCCESS.