def test_handle_pydantic_v2_validation_errors(self):
        """Test pydantic v2 ValidationError is correctly handled and converted to error response"""
        error = pydantic.ValidationError.from_exception_data(
            title='SearchQuery',
            line_errors=[InitErrorDetails(
                type=PydanticCustomError('type1', 'some message'), loc=('doc',), input=...)]
        )
        with patch("marqo.tensor_search.tensor_search.search", side_effect=error):
            response = self.client.post("/indexes/" + self.structured_index.name + "/search?device=cpu", json={
                "q": "test",
                "filter": ""
            })

            self.assertEqual(response.status_code, 400)
            self.assertEqual(response.json()["code"], InvalidArgError.code)
            self.assertEqual(response.json()["type"], InvalidArgError.error_type)
            assert "some message" in response.json()["message"]
Test pydantic v2 ValidationError is correctly handled and converted to error response
tests/integ_tests/tensor_search/test_api.py