Number two and three are both the same underlying bug and it has a name: you piped a command into something that does not care whether it succeeded.
set -o pipefail catches the whole class. Without it, the exit status of a pipeline is the status of the last command, so a failing tool piped into a happy grep is a success as far as the shell is concerned. With set -euo pipefail at the top of the file, both of those stop silently and start loudly.
It is one line and it is the difference between a script that reports and a script that performs.