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

How is throw handled during a for_each loop? #823

Open
e-gineer opened this issue Apr 3, 2024 · 1 comment
Open

How is throw handled during a for_each loop? #823

e-gineer opened this issue Apr 3, 2024 · 1 comment
Labels
bug Something isn't working stale

Comments

@e-gineer
Copy link
Contributor

e-gineer commented Apr 3, 2024

I have a for_each loop for an input step.

I'd like to run them in parallel, but stop waiting for inputs if any of them get a specific response (e.g. answer = deny).

How can I do that?

Current approach is to use a for_each and then throw { ... } when I get the deny. I expected that to break the for_each loop for me.

But - currently it seems to wait for each instance of the for_each to complete before breaking out based on the throw.

Should throw break the for_each loop? I believe an error/throw breaks execution if there are other parallel steps running, so I'd expect it to behave the same here?

  step "pipeline" "approve" {
    for_each = param.approvers

    pipeline = pipeline.single_approval

    args = {
      approver = each.value
      subject = param.subject
      prompt = param.prompt
      timeout = param.timeout
      default_decision = param.default_decision
    }

    throw {
      if = !result.output.approved
      message = "Approval failed"
    }

  }
@e-gineer e-gineer added the bug Something isn't working label Apr 3, 2024
Copy link

github-actions bot commented Jun 3, 2024

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the stale label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

1 participant