<#4693 Flytekit cant raise exception for Pydantic ...
# flyte-github
c
#4693 Flytekit cant raise exception for Pydantic v2 ValidationError Issue created by jganbat-fn on <!date^1704769959^{date_short}|2024-01-09T03:12:39Z> Hello Flyte folks, so I am updating our flytekit and we recently migrated to pydantic v2 on our model validation. however I am getting the following. Test runs like below • There is a unit test with pytest.raises that should raise ValidationError • This unit test calls flyte task that includes the pydantic model validation • However the test does not return the underlying ValidationError rather return the following
TypeError: No constructor defined
. I can see the underlying ValidationError exception but also see
During handling of the above exception, another exception occurred:
This
TypeError
happens at
flytekit/exceptions/scopes.py:user_entry_point
at this line216
Copy code
raise type(exc)(f"Error encountered while executing '{fn_name}':\n  {exc}") from exc
E                   TypeError: No constructor defined
it looks like pydantic v2 we need to raise specific error like https://github.com/pydantic/pydantic/issues/8026|this. I think we can just raise the original exception here right?
Copy code
except Exception as exc:
    raise exc
flyteorg/flyte