707cff6538b51939df30f84525ff9295b1b17e10
braney
  Thu Aug 13 15:21:23 2026 -0700
geneReviews otto: say FAILED in the subject when the run fails, refs #38098

A failed run mailed otto-group with the same "GENEREVIEW Build" subject as a
good one, and opened with the same routine hgLoadBed and bedToBigBed output. The
only sign of trouble was two lines at the bottom. Four failures went out that way
between July 21 and August 11 and read like four normal weekly updates.

Run the job to a log first so the exit status can choose the subject. A failure
now arrives as "GENEREVIEW Build FAILED" with the exit code appended to the body,
and the wrapper exits with the job's status rather than mail's.

Two smaller things fall out of the same change. A failure that produced no output
used to hit mail -E and be discarded, so it was silent; that case is now always
mailed. And the run output is kept in lastRun.log for anyone looking into a
failure after the fact.

A week where NCBI posts nothing still produces no output and no mail.

diff --git src/hg/utils/otto/geneReviews/geneReviewsWrapper.sh src/hg/utils/otto/geneReviews/geneReviewsWrapper.sh
index 154d6ddae7e..b0611be9924 100755
--- src/hg/utils/otto/geneReviews/geneReviewsWrapper.sh
+++ src/hg/utils/otto/geneReviews/geneReviewsWrapper.sh
@@ -1,8 +1,28 @@
 #!/bin/sh -e
 
 PATH=/cluster/bin/x86_64:$PATH
 EMAIL="otto-group@ucsc.edu"
 WORKDIR="/hive/data/outside/otto/geneReviews"
+LOG="$WORKDIR/lastRun.log"
 
+umask 002
 cd $WORKDIR
-./checkGeneReviews.sh $WORKDIR 2>&1 | mail -E -s "GENEREVIEW Build" $EMAIL
+
+# Run to a log first, so the exit status can pick the subject.  A failed run used
+# to arrive with the same "GENEREVIEW Build" subject as a good one, and opened
+# with the same routine build output, so six weeks of failures read like six
+# weeks of normal updates.  See #38098.
+./checkGeneReviews.sh $WORKDIR > $LOG 2>&1 && rc=0 || rc=$?
+
+if [ $rc -eq 0 ]
+then
+    # A week where NCBI posts nothing produces no output at all.  mail -E drops
+    # the empty message, which is how the job stays quiet with nothing to say.
+    mail -E -s "GENEREVIEW Build" $EMAIL < $LOG
+else
+    # Send on failure even if the run somehow produced no output.
+    echo "checkGeneReviews.sh exited $rc" >> $LOG
+    mail -s "GENEREVIEW Build FAILED" $EMAIL < $LOG
+fi
+
+exit $rc