# Naming task runs based on inputs

Tasks in Prefect provide a way for dynamically naming task runs based on the inputs provided to them from upstream tasks. Creating a dynamic task run name is a great way to help identify errors that may occur in a flow, for example, easily showing which mapped task failed based on the input it received. See the page on templating for details on how dynamically templated names work.

Backend Only

This feature only works when running in the context of an API backend run using something like the Prefect Server or Prefect Cloud.

In the example snippet below we have a flow that maps over a set of data returned from an upstream task and (for demonstration purposes) it raises an error when it receives the demo string as an input.

task runs no names

In the image above we can identify that one of our mapped children tasks failed however we are unable to identify exactly which task failed based on this information alone. This is where providing a template to the task's task_run_name kwarg comes in handy.


The backend will template the task run's name based on the val input it receives:

task runs with names

Now we can identify that the task with the demo input is the one that failed!