1, Don't be a douche. (Applies to players and GM equally)
2 There is no "right way". Any way of playing is fine as long as everyone is on the same page. Communication is key.
2, Failure is and should always be a possibility -don't put an obstacle/encounter in or call for a test unless you are prepared for it to fail or the party to be defeated. (It's a thing I see in a lot in adventures where there is, for example, a hidden door that calls for a check to be discovered but needs to be found for the adventure to progress)
3, Just because a player rolls doesn't automatically mean they have agency or are in control. It just means the result is being randomised. (Related to number 2, but I'm mainly talking to you -passive perception checks). Player agency means they get to make choices.
4 Having to make sh*t up on the fly for half the session as it didn't go the way you expected, doesn't mean you did something wrong or prepared badly it just means you've got mad skills. Bask in your achievement.
5 Don't sweat it. If it's not adding anything it's not needed. Skip it, drop it, whatever. If you need to bring it back later just let the players know up front.