Hello Flyte folks, so I am updating our flytekit a...
# ask-the-community
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:
happens at
at this line
Copy code
except Exception as exc:
>                   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 this. Does anyone have this issue
i tried just the
raise exc
and that seem to work as well 😅
Indeed, I think this should probably be considered a bug in flytekit. This
pattern that is used here and elsewhere in flytekit is fragile and makes a lot of assumptions about a user's exception types that might not be true (in this case, the exception in question doesn't have a
and can't even be called like this. Should either just reraise the same exact exception, or an exception type that is under Flyte's control.
CC: @Ketan (kumare3)
Thank you can you please file a bug