Skip to content

getInput returns undefined when an empty string is used as input for optional task input #1113

@ryenus

Description

@ryenus

We have an optional task input parameter named dockerImage in our custom azure task:

    {
      "name": "dockerImage",
      "type": "string",
      "label": "Docker Image",
      "defaultValue": "",
      "required": false,
      "helpMarkDown": "The Docker image to run the step in.",
      "groupName": "docker"
    }

When the input parameter is omitted, getInput returns undefined as we'd expected, however, when the user explicitly set dockerImage to an empty string using dockerImage: "", we also got undefined instead of an zero length string as we would expect.

We'd expect a fix so that we could:

  1. activate a fallback logic when the input is omitted / undefined
  2. skip docker container creation if the input is an empty string / ''

Currently we use azure-pipelines-task-lib 4.4.0 but the issue likely has existed for years.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions