ActivityCompleted but State is marked as Failed

I have a workflow with one state. That state’s API sometimes takes 1-2 seconds and sometimes takes more than 10 seconds.
Whenever it takes 1-2 seconds, the workflow completes successfully and I can see my state marked as successful in the logs of the ActivityTaskCompleted but for the other case, my AcitivityTaskCompleted shows my state as a failed state and shows the next state as a sidelineState.

I have set the startToCloseTimeout to 1minute which is very safe. The scheduletoclose timeout is also set to 2 minutes.

The API runs well when I try manually.

Can you share the executions event history json?