From c6fed5e8c355f8bb3f4636410046d5caef2c32a9 Mon Sep 17 00:00:00 2001 From: Armen Date: Fri, 11 Mar 2022 10:57:24 -0500 Subject: [PATCH] fix(dev): Errors within lib.sh were not being reported to Sentry This was regressed in #24512 --- .envrc | 7 ++++--- scripts/lib.sh | 11 ++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.envrc b/.envrc index 910591bdad0ca7..ac988857690936 100644 --- a/.envrc +++ b/.envrc @@ -58,9 +58,8 @@ report_to_sentry() { if ! require sentry-cli; then curl -sL https://sentry.io/get-cli/ | bash fi - # Report to sentry-dev-env - SENTRY_DSN="https://9bdb053cb8274ea69231834d1edeec4c@o1.ingest.sentry.io/5723503" \ - sentry-cli send-event -m "$error_message" --logfile "$_SENTRY_LOG_FILE" --level $log_level + # Report to sentry-dev-env project + sentry-cli send-event -m "$error_message" --logfile "$_SENTRY_LOG_FILE" --level $log_level rm "$_SENTRY_LOG_FILE" } @@ -143,6 +142,8 @@ fi if [ -n "${SENTRY_DEVENV_NO_REPORT+x}" ]; then debug "No development environment errors will be reported (since you've defined SENTRY_DEVENV_NO_REPORT)." else + # This is necessary for the bash-hook in lib.sh to work + export SENTRY_DSN="https://9bdb053cb8274ea69231834d1edeec4c@o1.ingest.sentry.io/5723503" # Since direnv traps the EXIT signal we place the temp file under /tmp for the odd time # the script will use the EXIT path _SENTRY_LOG_FILE=$(mktemp /tmp/sentry.envrc.$$.out || mktemp /tmp/sentry.envrc.XXXXXXXX.out) diff --git a/scripts/lib.sh b/scripts/lib.sh index 6f9dd01687de31..f6be6bff3b9dfc 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -1,4 +1,7 @@ #!/bin/bash +# NOTE: This file is sourced in CI across different repos (e.g. snuba), +# thus, renaming this file or any functions can break CI! +# # Module containing code shared across various shell scripts # Execute functions from this module via the script do.sh # shellcheck disable=SC2034 # Unused variables @@ -15,19 +18,13 @@ fi venv_name=".venv" -# NOTE: This file is sourced in CI across different repos (e.g. snuba), -# so renaming this file or any functions can break CI! - # Check if a command is available require() { command -v "$1" >/dev/null 2>&1 } configure-sentry-cli() { - # XXX: For version 1.70.1 there's a bug hitting SENTRY_CLI_NO_EXIT_TRAP: unbound variable - # We can remove this after it's fixed - # https://github.com/getsentry/sentry-cli/pull/1059 - export SENTRY_CLI_NO_EXIT_TRAP=${SENTRY_CLI_NO_EXIT_TRAP-0} + # SENTRY_DSN is currently exported in .envrc if [ -n "${SENTRY_DSN+x}" ] && [ -z "${SENTRY_DEVENV_NO_REPORT+x}" ]; then if ! require sentry-cli; then curl -sL https://sentry.io/get-cli/ | bash