<@ULVA73B9P> I have prefect install in k8s, I have...
# ask-marvin
r
@Marvin I have prefect install in k8s, I have some deployments configured with flow run names set based on a template. For every deployment, I have pull steps configured which configure the environment (it takes some time). I have a kinda generic deployment that I use for multiple source of data but every run is specific for a data source. Is it normal that when I run a flow from a deployment, during its pull steps, the flow run name isn't accessible and it compounded of a slug name ? I can only access the real flow run name when the state passes to "RUNNING". This is really annoying because I have a frontend from which I can run flows but I cannot display a flow that I've run since its name doesn't match.
m
thought for 493.9 seconds
Short answer: yes, that’s expected behavior today. What you’re seeing is how Prefect resolves flow run names in deployments. When a run is first created (SCHEDULED/PENDING and while the worker is doing pull steps), the run is given a temporary slug-style name. The deployment’s
flow_run_name
template is applied by the engine when the run actually starts (i.e., as it transitions to RUNNING). That’s why you only see the “real” name once it’s RUNNING, and why it’s not available during pull steps. A few practical ways to work around this for your frontend: - Set the run name up-front when you create the run - If you’re triggering programmatically, you can pass a name that will be set immediately and won’t be replaced by the template:
Copy code
from prefect.deployments.flow_runs import run_deployment

  flow_run = await run_deployment(
      name="my-flow/my-deployment",
      parameters={"source": "acme"},
      flow_run_name="ingest-acme-2025-12-08T12:00Z",
      # optional: tags=["source:acme"]
  )
- If you’re calling the REST API, use the “create flow run from deployment” endpoint and include a name in the payload; it will be used at creation time. - Immediately update the run name after you create it - If your frontend already creates the run and gets the run ID back, you can rename it right away so your UI shows the right name before RUNNING:
Copy code
from prefect.client.orchestration import get_client
  from prefect.client.schemas.actions import FlowRunUpdate

  async def set_name(flow_run_id: str, new_name: str):
      async with get_client() as client:
          await client.update_flow_run(flow_run_id, FlowRunUpdate(name=new_name))
- Tag runs for early discoverability - If you can’t set the name at creation, consider adding a tag like
source:acme
when you create the run. Your frontend can show/filter by that tag immediately, then swap to the final name when the run transitions to RUNNING. The Python helper above accepts
tags=...
and the REST endpoint accepts tags as well. Questions to help me tailor the best fix: - Are you on Prefect 3.x? - How are you triggering runs from your frontend (Python client, REST, or CLI)? - Are you able to compute the final name in your frontend (e.g., based on the same parameters you pass)? If so, setting it at creation will give you the exact behavior you want. If it’d be helpful, I can also sketch the exact REST call payload for your setup.