ReduceOnly order was raised even though it shouldnt

I was working with limit and got error 2022(ReduceOnly order).
I have experienced this error before but whats weird about this is that the order was made even though binance api raised an error.

order symbol newClientOrderId side price quantity position
limit LRCUSDT stop_profit BUY 0.31684 340. Short
(dualSidePosition=True, I was trying to close a position)

the log shows that i was trying to make limit with qty 340. which I had and even though the error was made I found the limit added to my binance account. why is this happening and how can i prevent if from happening