Repository: PrefectHQ/prefect
Issue category: Bug Report

Issue:
Missconfigured retry_delay_seconds task argument leads to confusing error message
### Bug summary

When the task arg `retry_delay_seconds` is not configured with the correct type, the error message presented is misleading:
```python
from datetime import timedelta
from prefect import get_run_logger, task, flow

@task(retries=1, retry_delay_seconds=timedelta(seconds=1)) #  retry_delay_seconds should be something like an int
def tasky():
    logger = get_run_logger()
    logger.info("hi")

@flow
def flowy():
    tasky()

flowy()
```

The resulting error message is:
```
09:33:08.239 | ERROR   | Flow run 'private-bittern' - Crash detected! Execution was interrupted by an unexpected exception: ValidationError: 2 validation errors for TaskRunPolicy
retry_delay
  value is not a valid integer (type=type_error.integer)
retry_delay
  value is not a valid list (type=type_error.list)
```

Notice is mentions `retry_delay`, not `retry_delay_seconds`

### Version info

```Text
Version:             2.20.13
API version:         0.8.4
Python version:      3.10.13
Git commit:          4d50c394
Built:               Wed, Nov 13, 2024 8:48 AM
OS/Arch:             darwin/arm64
Profile:             default
Server type:         cloud
```





Hints:

Patch:
diff --git a/src/prefect/tasks.py b/src/prefect/tasks.py
index d4e7d2fbce52..0d6610009847 100644
--- a/src/prefect/tasks.py
+++ b/src/prefect/tasks.py
@@ -474,6 +474,10 @@ def __init__(
 
         if callable(retry_delay_seconds):
             self.retry_delay_seconds = retry_delay_seconds(retries)
+        elif not isinstance(retry_delay_seconds, (list, int, float, type(None))):
+            raise TypeError(
+                f"Invalid `retry_delay_seconds` provided; must be an int, float, list or callable. Received type {type(retry_delay_seconds)}"
+            )
         else:
             self.retry_delay_seconds = retry_delay_seconds
 


Test patch:
diff --git a/tests/test_tasks.py b/tests/test_tasks.py
index 88cc1c4d086a..06d41abd6423 100644
--- a/tests/test_tasks.py
+++ b/tests/test_tasks.py
@@ -4172,6 +4172,21 @@ def my_flow():
 
 
 class TestTaskConstructorValidation:
+    async def test_task_cannot_configure_poorly_typed_retry_delay(self):
+        with pytest.raises(TypeError, match="Invalid"):
+
+            @task(retries=42, retry_delay_seconds=dict(x=4))
+            async def insanity():
+                raise RuntimeError("try again!")
+
+        with pytest.raises(TypeError, match="Invalid"):
+
+            @task(retries=42, retry_delay_seconds=2)
+            async def sanity():
+                raise RuntimeError("try again!")
+
+            more_insanity = sanity.with_options(retry_delay_seconds=dict(x=4))  # noqa: F841
+
     async def test_task_cannot_configure_too_many_custom_retry_delays(self):
         with pytest.raises(ValueError, match="Can not configure more"):