lucian
10/27/2025, 12:32 PMMarvin
10/27/2025, 12:32 PMMarvin
10/27/2025, 12:40 PM@dataclass(frozen=True) or a Pydantic model configured as frozen) so Python can’t set its __traceback__ attribute when the exception is raised. It’s a Python limitation, not specific to Prefect.
In Prefect 3.x, failures are captured into a Failed state (see how exceptions are handled in prefect.states), but the underlying issue here is the exception object itself being immutable.
What to do:
- If it’s your exception class, remove “frozen”:
# problematic
@dataclass(frozen=True)
class MyError(Exception):
msg: str
# fix
@dataclass # no frozen=True
class MyError(Exception):
msg: str
- If it comes from a third‑party library, catch and re‑raise a standard mutable exception:
try:
call_library()
except SomeFrozenLibError as e:
raise RuntimeError(f"Upstream error: {e}") from e
- If you also run into issues persisting results or exceptions, you can adjust result persistence/serialization, but note this won’t fix a frozen exception at raise time. For reference: Results in Prefect 3.x.
A couple questions to help confirm:
- Are you raising a custom exception that’s a @dataclass(frozen=True)?
- If not, which library is throwing the exception? Can you share the exception class or a snippet of the stack trace around the raise?