Skip to content

Backend: migrate ENABLE_DONATIONS to donations_enabled feature flag#8771

Merged
aapeliv merged 1 commit into
developfrom
backend/feature/donations-feature-flag
May 24, 2026
Merged

Backend: migrate ENABLE_DONATIONS to donations_enabled feature flag#8771
aapeliv merged 1 commit into
developfrom
backend/feature/donations-feature-flag

Conversation

@aapeliv

@aapeliv aapeliv commented May 23, 2026

Copy link
Copy Markdown
Member

Migrates the ENABLE_DONATIONS env toggle to a donations_enabled feature flag (GrowthBook), so donations can be turned on/off remotely without a deploy. This is the first of Project 1 — moving ENABLE_* functionality toggles onto the feature flag system.

Policy this establishes for ENABLE_* → flag migrations:

  • The runtime gate becomes a per-request flag: context.get_boolean_value("donations_enabled", default=False) (fails closed when experimentation is off/unconfigured).
  • Paired credentials (STRIPE_*) stay in env. Since the flag can be flipped on remotely at any time, the boot-time guarantee can no longer be gated on an enable-bit, so prod now requires the Stripe creds unconditionally (moved into the if not DEV: block) and screams loudly at boot if any are missing.
  • No runtime degrade-gracefully guard: prod is guaranteed configured, so a flip always works.

Ops: create donations_enabled in GrowthBook (default = prod's current donations state) before/at deploy. Until configured, the in-code default (False) applies.

Testing

  • make format clean; make mypy reports only the 2 pre-existing unrelated errors.
  • test_donations.py 10/10 — dropped the now-unnecessary ENABLE_DONATIONS=True patches (the flag defaults on in tests via EXPERIMENTATION_PASS_ALL_GATES), and added test_donations_disabled, which uses the shared feature_flags fixture to force the gate off and asserts the UNAVAILABLE / "Donations are currently disabled." abort.
  • Adjacent suites (experimentation/account/public) 71/71.

Backend checklist

  • Added tests for any new code or added a regression test if fixing a bug
  • Run the backend locally and it works
  • Added migrations if there are any database changes, rebased onto develop if necessary for linear migration history (n/a — no DB changes)

For maintainers

  • Maintainers can push commits to my branch
  • Maintainers can merge this PR for me

This PR was created with the Couchers PR skill.

…ture flag

Replace the static ENABLE_DONATIONS env config with a per-request
`donations_enabled` feature flag so donations can be toggled remotely
without a deploy. The Stripe credentials stay in env and are now required
in production unconditionally (since the flag can be flipped on at any
time), failing loudly at boot if missing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel

vercel Bot commented May 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
couchers Ready Ready Preview May 23, 2026 10:08pm

Request Review

@aapeliv
aapeliv marked this pull request as ready for review May 24, 2026 00:55
@aapeliv
aapeliv merged commit 1f66d40 into develop May 24, 2026
6 checks passed
@aapeliv
aapeliv deleted the backend/feature/donations-feature-flag branch May 24, 2026 00:55
@github-actions

Copy link
Copy Markdown
Contributor

📝 Release Notes

This PR does not need to be included in release notes.

Reason: This change is primarily an internal backend/configuration migration from an environment variable to a feature flag. While it improves operational flexibility for turning donations on or off without a deploy, it does not add or noticeably change functionality for end users, and it is not a major enough technical infrastructure change to surface in user-facing release notes.

🤖 Bot Debug Information

Model: couchers.openai.gpt-5.4
Decision: exclude
Reasoning: This change is primarily an internal backend/configuration migration from an environment variable to a feature flag. While it improves operational flexibility for turning donations on or off without a deploy, it does not add or noticeably change functionality for end users, and it is not a major enough technical infrastructure change to surface in user-facing release notes.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant