diff --git a/nixos/modules/monitoring/exporters/tahoe.nix b/nixos/modules/monitoring/exporters/tahoe.nix
index b04d69dbf56cc96b81c841e41011c691b973ead7..b891804c2d9c7e56e04277370b15a6dd12146f36 100644
--- a/nixos/modules/monitoring/exporters/tahoe.nix
+++ b/nixos/modules/monitoring/exporters/tahoe.nix
@@ -62,6 +62,7 @@ in {
         # textfile collector won't read a partial file.
         # See https://github.com/prometheus/node_exporter#textfile-collector
         script = ''
+          set -euo pipefail
           NUM_CORRUPTION_ADVISORIES=$(find /storage/corruption-advisories/ -type f | wc -l)
           echo "tahoe_corruption_advisories_total $NUM_CORRUPTION_ADVISORIES" > "${cfg.outFile}.tmp"