Ali bin Abu Talib reported,

The Messenger of Allah ﷺ sent out an army and placed a man in command over them. The commander kindled a fire and ordered, "Enter it." Some people intended to enter it, while others said, "We only fled from the fire." The matter was mentioned to the Messenger of Allah ﷺ, and he said to those who had intended to enter it, "Had you entered it, you would have remained in it until the Day of Resurrection." To the others he spoke kindly. Abu Musa said in his version, he spoke good words to them. He also said, "There is no obedience in disobedience to Allah. Obedience is only in what is right."

Nasai 4210

Sahih

أخبرنا محمد بن المثنى ومحمد بن بشار قالا حدثنا محمد قال حدثنا شعبة عن زبيد الإيامي عن سعد بن عبيدة عن أبي عبد الرحمن

عن علي

أن رسول الله ﷺ بعث جيشا وأمر عليهم رجلا فأوقد نارا فقال ادخلوها فأراد ناس أن يدخلوها وقال الآخرون إنما فررنا منها فذكروا ذلك لرسول الله ﷺ فقال للذين أرادوا أن يدخلوها لو دخلتموها لم تزالوا فيها إلى يوم القيامة وقال للآخرين خيرا وقال أبو موسى في حديثه قولا حسنا وقال لا طاعة في معصية الله إنما الطاعة في المعروف

النسائي 4210صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Pledge of allegiance
Chapter
Recompense for one who commands disobedience and is obeyed
Numbering
Darussalam 4210
Nasai 4210