<@ULVA73B9P> Task run failed with exception: Froze...
# marvin-ai
l
@Marvin Task run failed with exception: FrozenInstanceError("cannot assign to field '__traceback__'")
m
thought for 450.6 seconds
That error usually means the task raised an exception class that’s “frozen” (e.g., a
@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”:
Copy code
# 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:
Copy code
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?