You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even with a retry policy configured, `NonRetryableError` will fail immediately without retrying.
184
184
185
+
#### Error type matching behavior
186
+
187
+
**Important:** Error type matching uses **exact class name comparison**, not `isinstance()` checks. This is because exception objects are serialized to gRPC protobuf messages, where only the class name (as a string) survives serialization.
188
+
189
+
**Key implications:**
190
+
191
+
-**Not inheritance-aware**: If you specify `ValueError` in `non_retryable_error_types`, it will only match exceptions with the exact class name `"ValueError"`. A custom subclass like `CustomValueError(ValueError)` will NOT match.
192
+
-**Workaround**: List all exception types explicitly, including subclasses you want to handle.
193
+
-**Built-in exception**: `NonRetryableError` is always treated as non-retryable, matched by the name `"NonRetryableError"`.
194
+
195
+
**Example:**
196
+
197
+
```python
198
+
from datetime import timedelta
199
+
from durabletask import task
200
+
201
+
# Custom exception hierarchy
202
+
classValidationError(ValueError):
203
+
pass
204
+
205
+
# This policy ONLY matches exact "ValueError" by name
206
+
retry_policy = task.RetryPolicy(
207
+
first_retry_interval=timedelta(seconds=1),
208
+
max_number_of_attempts=3,
209
+
non_retryable_error_types=[ValueError] # Won't match ValidationError subclass!
210
+
)
211
+
212
+
# To handle both, list them explicitly:
213
+
retry_policy = task.RetryPolicy(
214
+
first_retry_interval=timedelta(seconds=1),
215
+
max_number_of_attempts=3,
216
+
non_retryable_error_types=[ValueError, ValidationError] # Both converted to name strings
0 commit comments