Al-Sha'bi (may Allah have mercy on him) said: Two men came to Sayyiduna Ali (may Allah be pleased with him) and testified that this man had stolen, so Sayyiduna Ali (may Allah be pleased with him) cut off his hand. Then they brought another man and said: The real thief is this one; there was a mistake regarding the other. So Sayyiduna Ali (may Allah be pleased with him) did not accept their testimony regarding the second man, made them pay the blood money (of the hand) to the first man, and said: If I knew that you had done this deliberately, I would cut off the hands of you both.
Imam al-Bukhari (may Allah have mercy on him) mentioned it in the chapter heading.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنايات / 15977