flowpipe icon indicating copy to clipboard operation
flowpipe copied to clipboard

Can I have a param with a default value of null? It seems to fail with missing parameter.

Open e-gineer opened this issue 10 months ago • 0 comments

I'm trying to use an input step in a pipeline. I'd like to have the subject be optional in my pipeline as well (so it will default to use the prompt).

I first tried having a parameter default set to the value of another param, but that doesn't work (yet) -

So, now I was trying to use null for the param, e.g.

  param "prompt" {
    type = string
    default = "Do you approve?"
  }

  param "subject" {
    # type has to be any, since string cannot be set to null
    type = any
    default = null
  }

I then use it in a step like this:

  step "pipeline" "serial" {
    if = !param.parallel
    pipeline = pipeline.serial_approval
    args = {
      approvers = param.approvers
      prompt = param.prompt
      subject = param.subject
      approvals_required = param.approvals_required
      timeout = param.timeout
      default_decision = param.default_decision
    }
  }

But it always fails with:

~/src/flowpipe-mod-approval $ flowpipe --host http://localhost:7003 pipeline run test --verbose
[flowpipe] Execution ID: exec_co6n1tko47mr4504g12g
[test] Starting pipeline
[test.square_it] Starting pipeline
[test.square_it] Arg args = {
  "approvers": [
    "foo",
    "bar"
  ],
  "parallel": false,
  "prompt": "Should I square 2?",
  "timeout": 10
}
[test.square_it] Arg pipeline = approval.pipeline.approval
[test] Output errors = [
  {
    "error": {
      "detail": "missing parameter: subject",
      "instance": "fperr_co6n1tko47mr4504g14g",
      "status": 400,
      "title": "Bad Request",
      "type": "error_bad_request"
    },
    "pipeline": "",
    "pipeline_execution_id": "pexec_co6n1tko47mr4504g130",
    "step": "pipeline.square_it",
    "step_execution_id": "sexec_co6n1tko47mr4504g140"
  }
]
[test] Bad Request: missing parameter: subject
[test] Failed 17ms

I understand why it would fail if there was no default value ... but given I've set the default value for the parameter shouldn't it run with that value (even though it's null)?

e-gineer avatar Apr 03 '24 15:04 e-gineer