turbot / flowpipe

Flowpipe is a cloud scripting engine. Automation and workflow to connect your clouds to the people, systems and data that matters.
https://flowpipe.io
GNU Affero General Public License v3.0
361 stars 13 forks source link

Cannot use loop.index inside a input loop block? #816

Closed e-gineer closed 6 months ago

e-gineer commented 6 months ago

Version: v0.4.2

I'm trying to do use loop.index inside a loop of an input step, but am getting a parse error.

Code:

  step "input" "approve" {
    notifier = notifier[keys(param.approvers)[0]]

    type = "button"

    subject = param.subject

    prompt = param.prompt

    option "approve" {
      label = "Approve"
      style = "ok"
    }

    option "deny" {
      label = "Deny"
      style = "alert"
    }

    loop {
      until = result.value == "deny" || loop.index >= len(param.approvers)
      notifier = notifier[keys(param.approvers)[loop.index]]
    }

  }

Error:

2024-03-26 07:13:59 [flowpipe] error unable to start server: Internal Error: Failed to decode mod: failed to parse dependency: Bad Request: invalid property path: loop.index
(/Users/nathan/src/flowpipe-mod-approval/mod.fp:10,20-104,2)
vhadianto commented 6 months ago

The error message is misleading. This is a bug that is now fixed: https://github.com/turbot/pipe-fittings/commit/66dd47bfcfa6942fbda9da4ba1c45d9b481c9259

The real error is:

xpected nil, but got: perr.ErrorModel{Instance:"fperr_co1p23sbajf6a6bm9q3g", ID:"", Type:"error_internal", Title:"Internal Error", Status:500, Detail:"Failed to decode mod: Call to unknown function: There is no function named \"len\". Did you mean \"log\"?\n(/Users/victorhadianto/z-development/turbot/pipe-fittings/tests/flowpipe_mod_tests/input_step_with_loop/mod.fp:58,61-64)", ValidationErrors:[]*perr.ErrorDetailModel(nil)}

The error message fix will be released as part of v0.4.3.