Skip to content

Commit 19b740a

Browse files
authored
fix(dev): Do not export SENTRY_DSN in .envrc (#35440)
We started exporting SENTRY_DSN back in #32524 in order to fix errors in lib.sh not being reported. Having this variable exported can cause a lot of errors from a developers' development to show up as dev env errors. Exporting inside of lib.sh does not persist in the developers' environment.
1 parent 178b724 commit 19b740a

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

.envrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ report_to_sentry() {
5959
curl -sL https://sentry.io/get-cli/ | bash
6060
fi
6161
# Report to sentry-dev-env project
62-
sentry-cli send-event -m "$error_message" --logfile "$_SENTRY_LOG_FILE" --level $log_level
62+
SENTRY_DSN="https://[email protected]/5723503" \
63+
sentry-cli send-event -m "$error_message" --logfile "$_SENTRY_LOG_FILE" --level $log_level
6364
rm "$_SENTRY_LOG_FILE"
6465
}
6566

@@ -142,8 +143,6 @@ fi
142143
if [ -n "${SENTRY_DEVENV_NO_REPORT+x}" ]; then
143144
debug "No development environment errors will be reported (since you've defined SENTRY_DEVENV_NO_REPORT)."
144145
else
145-
# This is necessary for the bash-hook in lib.sh to work
146-
export SENTRY_DSN="https://[email protected]/5723503"
147146
# Since direnv traps the EXIT signal we place the temp file under /tmp for the odd time
148147
# the script will use the EXIT path
149148
_SENTRY_LOG_FILE=$(mktemp /tmp/sentry.envrc.$$.out || mktemp /tmp/sentry.envrc.XXXXXXXX.out)

config/hooks/pre-commit

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@ if sys.version_info.major < 3:
1616
try:
1717
import sentry_sdk
1818

19-
if os.environ.get("SENTRY_DSN"):
20-
sentry_sdk.init(dsn=os.environ["SENTRY_DSN"])
21-
else:
22-
sys.stdout.write(
23-
"WARNING: Errors in this file will not be reported to Sentry since SENTRY_DSN is not set.\n"
24-
"Use this command to report the issue: make direnv-help\n\n"
25-
)
19+
if not os.environ.get("SENTRY_DEVENV_NO_REPORT"):
20+
sentry_sdk.init(dsn="https://[email protected]/5723503")
2621
except ModuleNotFoundError:
2722
sys.stdout.write(
2823
"WARNING: Sentry SDK not installed, thus, errors will not be reported. Run: make install-py-dev\n"

scripts/lib.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ configure-sentry-cli() {
2828
# We can remove this after it's fixed
2929
# https://github.com/getsentry/sentry-cli/pull/1059
3030
export SENTRY_CLI_NO_EXIT_TRAP=${SENTRY_CLI_NO_EXIT_TRAP-0}
31-
if [ -n "${SENTRY_DSN+x}" ] && [ -z "${SENTRY_DEVENV_NO_REPORT+x}" ]; then
31+
if [ -z "${SENTRY_DEVENV_NO_REPORT+x}" ]; then
3232
if ! require sentry-cli; then
3333
curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=2.0.4 bash
3434
fi
35+
# This exported variable does not persist outside of the calling script, thus, not affecting other
36+
# parts of the system
37+
export SENTRY_DSN="https://[email protected]/5723503"
3538
eval "$(sentry-cli bash-hook)"
3639
fi
3740
}

0 commit comments

Comments
 (0)