Not able to reproduce results for looping through my smart contract

I have created a smart contract for lottery system where I can create multiple type of lotteries and multiple tickets can be purchased for specific lottery for which there can be more then 1 winner.
I am using openZepplin defender to automate the winner announce part. Now coming to the issue which I am facing, it runs successfully for the case where single winner needs to be announced, but it doesn't work if there are more then 1 winner to be announced. Most probably due to multiple loops.

:computer: Environment
I am using openzepplin defender in which I have created autotask and interacting with the smart contract which is on Goerli chain.

Can you please produce me some alternative?

Please share the relevant code.

Your saying something doesn’t work without providing any useful information like your actual code or transaction information. Without that information no one here is able to help you.

Basically the scenario is:
I have used chainlink for generating unique winner(s). I want the winner(s) to be announced automatically when the raffle ends. For automation, I am using openZepplin's defender and automation, added code which will initially check the active raffles whose end time is reached and then call the function which is handling this. Now, the whole scenario is working for single winner. But when I do it for multi winner, it doesn't work. It exits with gas error.

Sharing you the instance of my code snippet from smart contract:

function getWinner(uint raffleId)
	internal
	returns (address[] memory)
{
	require(block.timestamp >= Raffles[raffleId].endTime,"The raffle has not closed yet");
	require(Raffles[raffleId].state == RaffleState.Open,"The raffle is not available for claiming");
	Raffles[raffleId].state = RaffleState.SelectingWinner;
	uint256 requestId = requestRandomWords();
	address[] memory ticketOwners = GetRaffleParticipant[raffleId].uniqueUsers;
	uint256 numWinners = Raffles[raffleId].winnersCount;
	// Generate random winner indices
	uint256[] memory winnerIndices = generateRandomIndices(numWinners,ticketOwners.length);
	// Declare an array to store the winners
	address[] memory winners = new address[](numWinners);
	uint256[] memory amountArr = rafflePrize[raffleId].ethArr;
	for (uint256 i = 0; i < numWinners; i++) {
		address winner = ticketOwners[winnerIndices[i]];
		winners[i] = winner;		
		emit WinnerChosen(raffleId, winner, winnerIndices[i]);
	}
	Raffles[raffleId].winnersAddress = winners;
	return winners;
}

function generateRandomIndices(uint256 numWinners, uint256 numTickets)
	internal
	view
	returns (uint256[] memory)
{
	uint256[] memory allIndices = new uint256[](numTickets);
	for (uint256 i = 0; i < numTickets; i++) {
		allIndices[i] = i;
	}
	uint256[] memory selectedIndices = new uint256[](numWinners);
	for (uint256 i = 0; i < numWinners; i++) {
		uint256 randomIndex = randomWordsNum % (numTickets - i);
		selectedIndices[i] = allIndices[randomIndex];
		allIndices[randomIndex] = allIndices[numTickets - i - 1];
	}
	return selectedIndices;
}
//new code
function requestRandomWords() public returns (uint256 requestId) {
	requestId = COORDINATOR.requestRandomWords(
		keyHash,
		s_subscriptionId,
		requestConfirmations,
		callbackGasLimit,
		numWords
	);
	s_requests[requestId] = RequestStatus({
		randomWords: new uint256[](0),
		exists: true,
		fulfilled: false
	});
	requestIds.push(requestId);
	lastRequestId = requestId;
	emit RequestSent(requestId, numWords);
	return requestId; // requestID is a uint.
}
function fulfillRandomWords(
	uint256 _requestId,
	uint256[] memory _randomWords
) internal override {
	require(s_requests[_requestId].exists, "request not found");
	s_requests[_requestId].fulfilled = true;
	s_requests[_requestId].randomWords = _randomWords;
	randomWordsNum = _randomWords[0]; // Set array-index to variable, easier to play with
	emit RequestFulfilled(_requestId, _randomWords);
}
// to check the request status of random number call.
function getRequestStatus(uint256 _requestId)
	external
	view
	returns (bool fulfilled, uint256[] memory randomWords)
{
	require(s_requests[_requestId].exists, "request not found");
	RequestStatus memory request = s_requests[_requestId];
	return (request.fulfilled, request.randomWords);
}

Please share ALL the relevant code and ONLY the relevant code.

For example (ALL), what function in this contract are you trying to execute, and what input values are you passing to it (when it reverts, and when it completes successfully)?

For example (ONLY), there are a bunch of internal functions here that aren't being called by any public or external function, so one can only assume that they are not related to your problem.

Also, note that there is an inherent problem in allIndices[numTickets - i - 1], since the value of i, which ranges between 0 and numWinners - 1, may very well be larger than numTickets - 1, which would lead to an attempt to access the array at a negative index.

Thank you for your response. Actually this logic in generateRandomIndices function is already working in the smart contract where the winner is being announced manually for single raffle, which means there is no problem in the logic and loop of this part. Rather some problem with openZepplin dealing with loops.

I sincerely doubt this.

Other than that, you have not referred to any of the points which I gave you (in two separate comments above), so I obviously cannot help you further.

I gave all relevant functions and also functions which are in use for chainlink. Can you please let me know what is missing or not relevant according to you? Mainly I am getting error for winner announcement function.

Please read this comment again.