Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the errorLogs() function captures error logs from a script #6083

Closed
anna-geller opened this issue Nov 25, 2024 · 7 comments · Fixed by #6106
Closed

Ensure that the errorLogs() function captures error logs from a script #6083

anna-geller opened this issue Nov 25, 2024 · 7 comments · Fixed by #6106
Labels
area/backend Needs backend code changes bug Something isn't working

Comments

@anna-geller
Copy link
Member

Feature description

id: error_logs_demo
namespace: company.team

tasks:    
  - id: fail
    type: io.kestra.plugin.scripts.python.Script
    taskRunner:
      type: io.kestra.plugin.core.runner.Process
    script: |
      raise ValueError("An error occurred: This is a manually raised exception.")
errors:
  - id: alert
    type: io.kestra.plugin.core.log.Log
    message: list of error logs — {{ errorLogs() }}

Another example:

id: error_logs_demo
namespace: company.team

tasks:    
  - id: fail
    type: io.kestra.plugin.scripts.python.Script
    taskRunner:
      type: io.kestra.plugin.core.runner.Process
    script: |
      def divide_numbers(a, b):
          return a / b

      result = divide_numbers(5, 0)
      print(result)

errors:
  - id: alert
    type: io.kestra.plugin.core.log.Log
    message: list of error logs — {{ errorLogs() }}

The only error log it captures is Command failed with exit code 1 - the actual log with a reason why the task failed is not captured.

list of error logs — [{"namespace":"company.team","flowId":"error_logs_demo2","taskId":"fail","executionId":"41ClpgK5tLqp2WqKsM1U3c","taskRunId":"tfBn6QL2y51KtWxUDbWf7","attemptNumber":0,"timestamp":"2024-11-25T15:40:22.226Z","level":"ERROR","thread":"worker_4","message":"Command failed with exit code 1","deleted":false},{"namespace":"company.team","flowId":"error_logs_demo2","taskId":"fail","executionId":"41ClpgK5tLqp2WqKsM1U3c","taskRunId":"tfBn6QL2y51KtWxUDbWf7","attemptNumber":0,"timestamp":"2024-11-25T15:40:22.226Z","level":"ERROR","thread":"worker_4","message":"io.kestra.core.models.tasks.runners.TaskException: Command failed with exit code 1","deleted":false}]
@anna-geller anna-geller added bug Something isn't working area/backend Needs backend code changes labels Nov 25, 2024
@github-project-automation github-project-automation bot moved this to Backlog in Issues Nov 25, 2024
@wrussell1999
Copy link
Member

This is an example with S3 Copy that fails.

id: error_logs_demo
namespace: company.team

tasks:    
  - id: copy
    type: io.kestra.plugin.aws.s3.Copy
    accessKeyId: "<access-key>"
    secretKeyId: "<secret-key>"
    region: "eu-central-1"
    from:
      bucket: "my-bucket"
      key: "path/to/file"
    to:
      bucket: "my-bucket2"
      key: "path/to/file2"

errors:
  - id: alert
    type: io.kestra.plugin.core.log.Log
    message: list of error logs — {{ errorLogs() }}

Result:
Screenshot 2024-11-25 at 15 43 30

develop EE

@loicmathieu
Copy link
Member

@anna-geller for your two examples, Python wrote logs in WARNING that why they are not returned by the errorLogs() methods.

@anna-geller
Copy link
Member Author

anna-geller commented Nov 25, 2024

Python wrote logs in WARNING

yup, this is unfortunate since this is an actual error in the Python script (value error + zero division error)

@loicmathieu
Copy link
Member

It's because we log the standard error as WARNING and not ERROR

@anna-geller
Copy link
Member Author

can we change it? 🙏 we should (even if this would mean a BC)

@loicmathieu
Copy link
Member

can we change it? 🙏 we should (even if this would mean a BC)

This needs to be investigated and validated by Ludo, better to open a new issue to discuss that.

@anna-geller
Copy link
Member Author

ok, follow up issue kestra-io/plugin-scripts#190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend Needs backend code changes bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants