<@ULVA73B9P> how can I implement a drop down list ...
# ask-marvin
c
@Marvin how can I implement a drop down list of options for a flow parameter in a cloud deployment
m
thought for 171.9 seconds
In Prefect 3.x, the easiest way to get a dropdown for a deployment parameter in Prefect Cloud is to type the parameter as a constrained set of values using
Literal
or an
Enum
. Example with `Literal`:
Copy code
python
from typing import Literal
from prefect import flow

Environment = Literal["dev", "staging", "prod"]

@flow
def my_flow(environment: Environment = "dev"):
    print(f"Running in {environment}")
When this flow is deployed, the
environment
parameter should show up in the Cloud run form as a dropdown. If you want multiple selections, use a list of
Literal
values:
Copy code
python
from typing import Literal
from prefect import flow

Region = Literal["us-east-1", "us-west-2", "eu-west-1"]

@flow
def my_flow(regions: list[Region] = ["us-east-1"]):
    print(regions)
That should render as a multi-select dropdown. You can also do the same with an `Enum`:
Copy code
python
from enum import Enum
from prefect import flow

class Environment(str, Enum):
    DEV = "dev"
    STAGING = "staging"
    PROD = "prod"

@flow
def my_flow(environment: Environment = Environment.DEV):
    print(environment)
A few notes: - Prefect Cloud builds the form from the flow’s parameter OpenAPI schema -
enum
-style constraints are what drive the dropdown UI - You do not need to manually configure the form in most cases If you want nicer labels/descriptions, wrap parameters in a Pydantic model and use
Field(...)
metadata. Docs: - Form building in Prefect 3 - Deployments If you want, I can also show you a complete deployed example using
flow.from_source(...).deploy(...)
or
prefect deploy
.
c
@Marvin In Prefect Cloud Quick Run, the following flow renders the config parameter as a drop down but no values can be selected from it or searched. The values can however be selected in custom run on Prefect Cloud. The drop downs work as expected Prefect Server for both quick and custom runs. Is this a known bug?
'title': 'Parameters', 'required': ['config', 'config2', 'config3'], 'properties': {
m
thought for 225.9 seconds
c
Copy code
from typing import Literal
from prefect import flow

Small = Literal["a","b","c"]

@flow
def test_literal(config: Small):
    print(config)
m
This does sound like a real bug, and based on what you described, it appears to be Cloud UI-specific. Why I say that: - Custom Run in Prefect Cloud works - Quick Run in Prefect Cloud does not - Prefect Server works in both cases That strongly suggests the issue is not with your flow definition or parameter schema, but with the Quick Run frontend behavior in Cloud. A couple of useful observations: - Quick Run and Custom Run ultimately hit the same deployment run API path - Since Custom Run works, the underlying parameter schema is probably valid - Since Server works, this is likely not a general enum/Literal/dropdown rendering bug - So the most likely cause is a Cloud-only UI bug in the Quick Run experience, possibly around the dropdown popover/interaction layer I wasn’t able to confirm an existing public GitHub issue for this exact bug, and GitHub search was unavailable from my side right now, so I can’t confidently say it’s already tracked publicly. Recommended workaround: - Use Custom Run for deployments with dropdown/enum parameters in Prefect Cloud for now If you want to help narrow it down, a minimal repro would be something like:
Copy code
python
from typing import Literal
from prefect import flow

@flow
def test_flow(config: Literal["a", "b", "c"] = "a"):
    print(config)
If that behaves exactly the same in Cloud Quick Run, that’s a strong repro for a UI bug. Docs on form/schema behavior: - Form building in Prefect 3 - Deployments If you want, paste your exact flow signature and I can sanity-check whether there’s anything schema-related that might make Quick Run especially fragile.
c
@Marvin
Copy code
from typing import Literal
from prefect import flow

Small = Literal["a","b","c"]

@flow
def test_literal(config: Small):
    print(config)
m
thought for 6.0 seconds
Thanks — that example looks valid, and I’d expect
config
to render as a selectable dropdown. Your flow:
Copy code
python
from typing import Literal
from prefect import flow

Small = Literal["a","b","c"]

@flow
def test_literal(config: Small):
    print(config)
should produce an enum-style parameter schema for
config
, which is exactly the pattern Prefect uses for dropdowns. Given your earlier report: - Cloud Quick Run: dropdown appears but values can’t be selected/searched - Cloud Custom Run: works - Prefect Server Quick Run + Custom Run: both work I do not see anything wrong with the flow definition. This strengthens the case that it’s a Prefect Cloud Quick Run UI bug. A couple of extra notes: - You may get slightly more stable behavior if you add a default:
Copy code
python
  from typing import Literal
  from prefect import flow

  Small = Literal["a", "b", "c"]

  @flow
  def test_literal(config: Small = "a"):
      print(config)
But this should not be required for the dropdown to function. -
Literal[...]
is the correct way to define fixed choices in Prefect 3.x forms. So my best answer is: yes, this appears to be a bug, not misuse of the API. If you want to report it publicly, GitHub issues would be the right place: - Prefect issues Useful bug report details: - Prefect Cloud - deployment run form in Quick Run -
Literal[...]
parameter renders as dropdown but options are not clickable/searchable - same deployment works in Custom Run - same flow works in Prefect Server - include your minimal repro If you want, I can help you write a concise GitHub issue body for this exact reproduction.
c
@Marvin please write the issue body
m
thought for 9.7 seconds
Sure — here’s a concise issue body you can paste into GitHub:
Copy code
markdown
## Bug summary

In Prefect Cloud, a flow parameter typed with `typing.Literal[...]` renders as a dropdown in *Quick Run*, but the dropdown options cannot be selected or searched.

The same deployment works correctly in:
- *Custom Run* in Prefect Cloud
- *Quick Run* in Prefect Server
- *Custom Run* in Prefect Server

This appears to be a Cloud-only Quick Run UI bug.

## Minimal reproduction

```python
from typing import Literal
from prefect import flow

Small = Literal["a", "b", "c"]

@flow
def test_literal(config: Small):
    print(config)
## Steps to reproduce 1. Create a deployment for the flow above 2. Open the deployment in Prefect Cloud 3. Click Quick Run 4. Observe that the
config
parameter is rendered as a dropdown 5. Try to click or search for any of the values ## Expected behavior The dropdown should allow selecting one of the values: -
a
-
b
-
c
## Actual behavior The dropdown is rendered, but no values can be selected from it and searching does not work. ## Comparison Behavior differs by environment/run mode: | Environment | Quick Run | Custom Run | |------------|-----------|------------| | Prefect Cloud | broken | works | | Prefect Server | works | works | ## Notes - The flow parameter schema appears valid since the same parameter works in Custom Run - This seems specific to the Prefect Cloud Quick Run UI - Reproduced with a minimal
Literal[...]
parameter, no additional config required ``` Issue link: - Prefect GitHub issues If you want, I can also turn this into a shorter, more engineering-focused version.