Abdullah bin Abbas reported,

There were people who would question the Messenger of Allah ﷺ in mockery. One man would ask, "Who is my father?" Another, whose camel had strayed, would ask, "Where is my camel?" So Allah revealed concerning them this verse, "You who believe, do not ask about things which, if made clear to you, would grieve you" [Maidah 5:101], and he recited the verse through to its end.

Azami 1284

Sahih

عن ابن عباس، قال

كان: قوم يسألون رسول الله ﷺ استهزاء، فيقول الرجل: من أبي؟ ويقول الرجل تضل ناقته: أين ناقتي؟ فأنزل الله فيهم هذه الآية: {يأيها الذين ءامنوا لا تسألوا عن أشياء إن تبد لكم تسؤكم} حتى فرغ من الآية كلها.

الأعظمي 1284صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Knowledge
Chapter
Warnings in matters of knowledge
Section
Prohibition of excessive questioning about what has not occurred and about which no revelation has been sent down
Numbering
Jami al-Kamil 1284 (2nd edition)
Azami 1284