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

Respect ignore_error when calling another task from a command #363

Open
shilangyu opened this issue Aug 22, 2020 · 3 comments · May be fixed by #855
Open

Respect ignore_error when calling another task from a command #363

shilangyu opened this issue Aug 22, 2020 · 3 comments · May be fixed by #855
Labels
good first issue Issues that are good for first-time contributors to pick up. type: enhancement A change to an existing feature or functionality.

Comments

@shilangyu
Copy link
Contributor

shilangyu commented Aug 22, 2020

  • Task version: master
  • OS: Linux

When calling task other with the following Taskfiles:

this works, the error is ignored

version: "3"

tasks:
  bad:
    cmds:
      - exit 1
  other:
    cmds:
      - cmd: task bad
        ignore_error: true
      - echo hello

this does not work, nothing is printed

version: "3"

tasks:
  bad:
    cmds:
      - exit 1
  other:
    cmds:
      - task: bad
        ignore_error: true
      - echo hello
@andreynering andreynering added the type: enhancement A change to an existing feature or functionality. label Aug 25, 2020
@andreynering andreynering changed the title ignore_error does not work when calling other tasks Respect ignore_error when calling another task from a command Aug 25, 2020
@andreynering
Copy link
Member

Hi @shilangyu, thanks for opening this issue!

This doesn't work because it was not originally intended to work like this. It may makes sense to respect that, though...

@marco-m
Copy link
Contributor

marco-m commented Mar 22, 2021

@andreynering I stumbled upon this exact problem.
To me this is a bug, not an enhancement, for the following reason: adding ignore_error to a task has the effect that the task is silently skipped and the user doesn't even understand what is going on :-) If it was not intended to work like this, Task should fail reporting a syntax error I think...

EDIT
Ah sorry I take it back; with Task v3.3.0 I do get what I expect:

$ task other
task: exit 1
task: Failed to run task "other": task: Failed to run task "bad": exit status 1

I will create a separate ticket for the problem I stumbled upon

@ivotron
Copy link

ivotron commented Mar 25, 2021

My 2c is that ignore_error should work the same way when invoking another task. In my case, the workaround I came up with is to create another task that includes ignore_error: true and add an -ignore-error prefix to its name, so:

version: "3"

tasks:
  bad:
    cmds:
      - exit 1
  bad-ignore-error:
    ignore_error: true
    cmds:
      - exit 1
  other:
    cmds:
      - task: bad-ignore-error
      - echo hello

not ideal but gets the job done

@andreynering andreynering added the good first issue Issues that are good for first-time contributors to pick up. label Aug 4, 2022
@core-dev-crypto core-dev-crypto linked a pull request Sep 3, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that are good for first-time contributors to pick up. type: enhancement A change to an existing feature or functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants