Skip to content

fix(scripts): every known flags should be shifted before executing the sentry <foo> command #3831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 7, 2025

Conversation

aldy505
Copy link
Collaborator

@aldy505 aldy505 commented Jul 25, 2025

Fixes #3526

Previously, if this was executed:

./scripts/backup.sh --no-report-self-hosted-issues

The final backup command that will be executed is:

docker compose run -v "${PWD}/sentry:/sentry-data/backup" --rm -T -e SENTRY_LOG_LEVEL=CRITICAL web export --no-report-self-hosted-issues /sentry-data/backup/backup.json

Which is invalid. This PR strips all known flags specific to self-hosted before passing it onto Sentry.

One other option is to enable "ignore unknown options" on click (the CLI dependency) on Sentry, but I don't want to go to that route.

…e sentry <foo> command

Fixes #3526

Previously, if this was executed:
```bash
./scripts/backup.sh --no-report-self-hosted-issues
```

The final backup command that will be executed is:
```bash
docker compose run -v "${PWD}/sentry:/sentry-data/backup" --rm -T -e SENTRY_LOG_LEVEL=CRITICAL web export --no-report-self-hosted-issues /sentry-data/backup/backup.json
```

Which is invalid. This PR strips all known flags specific to self-hosted before passing it onto Sentry.

One other option is to enable "ignore unknown options" on click (the CLI dependency) on Sentry, but I don't want to go to that route.
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.45%. Comparing base (abe68ba) to head (65b47c0).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3831   +/-   ##
=======================================
  Coverage   99.45%   99.45%           
=======================================
  Files           3        3           
  Lines         183      183           
=======================================
  Hits          182      182           
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

MINIMIZE_DOWNTIME="${MINIMIZE_DOWNTIME:-}"
REPORT_SELF_HOSTED_ISSUES="${REPORT_SELF_HOSTED_ISSUES:-}"

while (($#)); do
Copy link
Member

Choose a reason for hiding this comment

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

Why not just add --minimize-downtime to the scripts/_lib.sh? That way we don't need to maintain 3 areas of similar logic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because it won't be shifted by Bash and would be included on the Docker command. The problem was this:

cmd="backup $1"
source scripts/_lib.sh
$cmd

If you do ./scripts/backup.sh --minimize-downtime, the resulting cmd would be backup --minimize-downtime. If you want to add another known flag for the backup script, like --silent, you would have to do backup --sillent --minimize-downtime. It will be hard to make users aware that they are not supposed to do backup --minimize-downtime --silent.

So if you omit those known flags before passing the command, it will work as expected. This also would open the possibility of doing cmd="backup $@" (I don't know if this correct, but I hope you get the right idea) to allow more than one parameter.

@aldy505 aldy505 merged commit 213423f into master Aug 7, 2025
14 checks passed
@aldy505 aldy505 deleted the fix/aldy505/scripts-flag-usage branch August 7, 2025 03:14
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

--no-report-self-hosted-issues flag doesn't work in backup command
2 participants