feat: update feature flags through bash script#4403
Draft
aldy505 wants to merge 3 commits into
Draft
Conversation
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
reviewed
Jul 9, 2026
aminvakil
left a comment
Collaborator
There was a problem hiding this comment.
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. |
Collaborator
There was a problem hiding this comment.
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") |
Collaborator
There was a problem hiding this comment.
Suggested change
| _end_line=$(wc -l <"$SENTRY_CONFIG_PY") | |
| return 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2533