Skip to content

feat: update feature flags through bash script#4403

Draft
aldy505 wants to merge 3 commits into
masterfrom
aldy505/feat/auto-update-feature-flag
Draft

feat: update feature flags through bash script#4403
aldy505 wants to merge 3 commits into
masterfrom
aldy505/feat/auto-update-feature-flag

Conversation

@aldy505

@aldy505 aldy505 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Closes #2533

aldy505 added 2 commits July 9, 2026 07:47
   Test 3 inserts an extra flag before the closing ) of the
   SENTRY_FEATURES block. The previous sed pattern /^)$/i matched
   every lone ) in sentry.conf.py, corrupting unrelated blocks
   before the script under test even ran. Now we compute the exact
   line number of the first ) after the SENTRY_FEATURES start
   marker and insert only there.

@aminvakil aminvakil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a corner case which this PR breaks self-hosted users flow.

Let's say a user has something like this for example:

SENTRY_FEATURES["projects:sample-events"] = False

GEOIP_PATH_MMDB = "/geoip/GeoLite2-City.mmdb"
CSRF_TRUSTED_ORIGINS = ["https://example.com"]

I mean when they do not have a SENTRY_FEATURES.update just after SENTRY_FEATURES for some reason, this PR with current commits would just remove everything the user has written afterwards (GEOIP, CSRF in this example) with SENTRY_FEATURES.update.

From a point of view, this may be ok for a user which has explictly stated APPLY_AUTOMATIC_CONFIG_UPDATES=1, but I still rather just skip and do not replace their whole script if SENTRY_FEATURES.update does not get found.

What do you think?

_end_line=$(awk -v start="$_start_line" 'NR > start && /^\)$/ { print NR; exit }' "$SENTRY_CONFIG_PY")

if [[ -z "$_end_line" ]]; then
# No closing `)` found before EOF, replace from start to EOF.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# No closing `)` found before EOF, replace from start to EOF.
echo "Could not find end of SENTRY_FEATURES.update block; skipping automatic feature flag update."


if [[ -z "$_end_line" ]]; then
# No closing `)` found before EOF, replace from start to EOF.
_end_line=$(wc -l <"$SENTRY_CONFIG_PY")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_end_line=$(wc -l <"$SENTRY_CONFIG_PY")
return 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Upgrading self-hosted should automatically enable new features

2 participants