@@ -796,6 +796,8 @@ def _results_message_to_execute_response(self, resp, operation_state):
796796arrow_queue_opt = None
797797
798798command_id = CommandId .from_thrift_handle (resp .operationHandle )
799+ if command_id is None :
800+ raise ValueError (f"Invalid Thrift handle:{ resp .operationHandle } " )
799801
800802return ExecuteResponse (
801803arrow_queue = arrow_queue_opt ,
@@ -1156,6 +1158,8 @@ def get_columns(
11561158
11571159def _handle_execute_response (self ,resp ,cursor ):
11581160command_id = CommandId .from_thrift_handle (resp .operationHandle )
1161+ if command_id is None :
1162+ raise ValueError (f"Invalid Thrift handle:{ resp .operationHandle } " )
11591163
11601164cursor .active_command_id = command_id
11611165self ._check_direct_results_for_error (resp .directResults )
@@ -1169,6 +1173,9 @@ def _handle_execute_response(self, resp, cursor):
11691173
11701174def _handle_execute_response_async (self ,resp ,cursor ):
11711175command_id = CommandId .from_thrift_handle (resp .operationHandle )
1176+ if command_id is None :
1177+ raise ValueError (f"Invalid Thrift handle:{ resp .operationHandle } " )
1178+
11721179cursor .active_command_id = command_id
11731180self ._check_direct_results_for_error (resp .directResults )
11741181