Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(workflows): enforce email sending tiers for every team at once (#92398)

Meikel Ratzbdabda1a9bc0
diff --git a/docs/internal/workflows-email-sending-tiers.md b/docs/internal/workflows-email-sending-tiers.md
index 9b01f068cd38..123445728a57 100644
--- a/docs/internal/workflows-email-sending-tiers.md
+++ b/docs/internal/workflows-email-sending-tiers.md
@@ -24,7 +24,6 @@ Django (`posthog/settings/web.py`):
- `WORKFLOWS_EMAIL_TIER_MODE`: `off` (default), `shadow`, or `enforce`. Unrecognized values read as `off`.
- `WORKFLOWS_EMAIL_TIER_HOURLY_CAPS`, `WORKFLOWS_EMAIL_TIER_DAILY_CAPS`, `WORKFLOWS_EMAIL_TIER_BATCH_AUDIENCE_CAPS`: comma-separated tables indexed by tier. The shortest table decides the tier count.
- `WORKFLOWS_EMAIL_TIER_MIN_DAYS_AT_TIER`: per-tier dwell before promotion, comma-separated, clamped to the last entry.
-- `WORKFLOWS_EMAIL_TIER_ENFORCE_TEAMS_CREATED_AFTER`: ISO date. Empty enforces every team; a valid date enforces only teams created on or after it; an unparseable value enforces nobody, so a typo narrows instead of widening.
- Promotion and demotion knobs: `WORKFLOWS_EMAIL_TIER_RATE_WINDOW_DAYS` (promotion window), `WORKFLOWS_EMAIL_TIER_DEMOTION_WINDOW_DAYS`, `WORKFLOWS_EMAIL_TIER_DEMOTION_COOLDOWN_DAYS` (keep at least as long as the demotion window), `WORKFLOWS_EMAIL_TIER_INACTIVITY_DECAY_DAYS` (0 disables decay), `WORKFLOWS_EMAIL_TIER_MIN_ACTIVE_DAYS`, `WORKFLOWS_EMAIL_TIER_MIN_DAILY_USE_RATIO`, `WORKFLOWS_EMAIL_TIER_MAX_COMPLAINT_RATE`, `WORKFLOWS_EMAIL_TIER_MAX_BOUNCE_RATE`, `WORKFLOWS_EMAIL_TIER_COMPLAINT_RATE_MIN_SENDS`, `WORKFLOWS_EMAIL_TIER_COMPLAINT_COUNT_BACKSTOP`, `WORKFLOWS_EMAIL_TIER_BOUNCE_RATE_MIN_SENDS`.
- `HOGFLOW_BATCH_TRIGGER_ELEVATED_TEAM_IDS`: the pre-tier allowlist. It overrides the tier entirely, so a saved tier does nothing for a listed team.
@@ -32,7 +31,6 @@ Worker (`nodejs/src/cdp/config.ts`):
- `EMAIL_TEAM_SENDING_CAP_MODE`: `off` (default), `shadow`, or `enforce`.
- `EMAIL_TEAM_SENDING_CAP_HOURLY_BY_TIER`, `EMAIL_TEAM_SENDING_CAP_DAILY_BY_TIER`: must mirror the Django tables. An unusable table turns the cap off rather than applying a wrong number.
-- `EMAIL_TEAM_SENDING_CAP_TEAMS_CREATED_AFTER`: same three-state semantics as the Django cutoff, except that empty caps every team and an unparseable value caps nobody.
All of these reach production as environment variables through `posthog/charts` (with any secret values via `posthog/secrets`).
None of them are wired there yet; the charts change is part of turning the rollout mode on, not part of merging the code.
@@ -48,7 +46,7 @@ Pinned teams never move automatically.
1. Merge and deploy with both modes `off`. The daily sweep starts computing and storing tiers immediately.
2. Run `python manage.py backfill_workflows_email_sending_tiers` per region, read the printed distribution, then re-run with `--apply`. This lands established senders on their earned tier in one step.
3. Set both modes to `shadow` via charts. Nothing is delayed; would-be delays log and count in `cdp_team_email_cap_delayed_total{mode="shadow"}`. Watch that against real traffic.
-4. Set both modes to `enforce`, optionally with the created-after cutoffs so only new projects are enforced first. The Reputation tab's allowance card appears for enforced teams at this point.
+4. Set both modes to `enforce`. Enforcement applies to every team at once; the Reputation tab's allowance card appears at this point.
Never set the Django mode to `enforce` on a deployment whose email worker does not carry the send-time caps: the batch audience cap alone can be sidestepped by editing a workflow while a batch is queued, and the send-time buckets are what bound that.
5. To back out, set the modes back to `off`; the tiers keep computing and nothing else changes.
@@ -58,3 +56,4 @@ Pinned teams never move automatically.
- Test-panel sends bypass the team buckets on purpose, matching the per-workflow rate limit.
- The buckets are token buckets: a full idle bucket plus refill allows up to roughly twice the stated cap in the very first period. The bucket TTLs exceed the refill periods so this does not recur from idling.
- Gmail provides no per-message feedback loop, so complaint rates (ours and AWS's) cannot see Gmail complaints at all.
+- The `HOGFLOW_BATCH_TRIGGER_ELEVATED_TEAM_IDS` allowlist elevates a team to the top tier in Django only: the UI, the admin, and the batch audience cap show top-tier numbers, but the worker's send-time buckets read the stored tier. An allowlisted team below the top tier is therefore throttled at its stored tier while being told otherwise, and its shadow-mode delay counts overstate real impact. Before enforcing, pin each allowlisted team at the top tier from the Django admin and empty the allowlist, rather than plumbing the list into the worker.
diff --git a/nodejs/src/cdp/cdp-services.ts b/nodejs/src/cdp/cdp-services.ts
index e9755fe71519..5795706af52b 100644
--- a/nodejs/src/cdp/cdp-services.ts
+++ b/nodejs/src/cdp/cdp-services.ts
@@ -162,7 +162,6 @@ export type CdpCoreServicesConfig = Pick<
| 'EMAIL_TEAM_SENDING_CAP_MODE'
| 'EMAIL_TEAM_SENDING_CAP_HOURLY_BY_TIER'
| 'EMAIL_TEAM_SENDING_CAP_DAILY_BY_TIER'
- | 'EMAIL_TEAM_SENDING_CAP_TEAMS_CREATED_AFTER'
| 'CDP_GOOGLE_ADWORDS_DEVELOPER_TOKEN'
| 'CONVERSATIONS_TICKETS_JWT_SECRET'
| 'CUSTOMER_ANALYTICS_ACCOUNTS_JWT_SECRET'
@@ -444,7 +443,6 @@ export function createCdpCoreServices(
teamEmailCapMode: parseTeamEmailCapMode(config.EMAIL_TEAM_SENDING_CAP_MODE),
teamEmailTierHourlyCaps: parseTierCaps(config.EMAIL_TEAM_SENDING_CAP_HOURLY_BY_TIER),
teamEmailTierDailyCaps: parseTierCaps(config.EMAIL_TEAM_SENDING_CAP_DAILY_BY_TIER),
- teamEmailCapTeamsCreatedAfter: config.EMAIL_TEAM_SENDING_CAP_TEAMS_CREATED_AFTER,
},
deps.integrationManager,
teamWorkflowsConfigService,
diff --git a/nodejs/src/cdp/config.ts b/nodejs/src/cdp/config.ts
index d37f0ef2139e..e7e05e8d96df 100644
--- a/nodejs/src/cdp/config.ts
+++ b/nodejs/src/cdp/config.ts
@@ -150,9 +150,6 @@ export type CdpConfig = ClickhouseConfig & {
// Comma-separated caps indexed by tier. Both lists must be the same length.
EMAIL_TEAM_SENDING_CAP_HOURLY_BY_TIER: string
EMAIL_TEAM_SENDING_CAP_DAILY_BY_TIER: string
- // ISO date. When set, only teams created on or after it are capped, so enforcement can start
- // with new projects and leave established ones alone. Empty means every team.
- EMAIL_TEAM_SENDING_CAP_TEAMS_CREATED_AFTER: string
// Destination migration diffing
DESTINATION_MIGRATION_DIFFING_ENABLED: boolean
@@ -345,7 +342,6 @@ export function getDefaultCdpConfig(): CdpConfig {
EMAIL_TEAM_SENDING_CAP_MODE: 'off',
EMAIL_TEAM_SENDING_CAP_HOURLY_BY_TIER: '50,200,600,2000,6000,20000,60000,200000',
EMAIL_TEAM_SENDING_CAP_DAILY_BY_TIER: '100,1000,3000,10000,30000,100000,300000,1000000',
- EMAIL_TEAM_SENDING_CAP_TEAMS_CREATED_AFTER: '',
// Destination migration diffing
DESTINATION_MIGRATION_DIFFING_ENABLED: false,
diff --git a/nodejs/src/cdp/services/managers/team-workflows-config.service.ts b/nodejs/src/cdp/services/managers/team-workflows-config.service.ts
index 3622974e2c98..1a943b4f4df0 100644
--- a/nodejs/src/cdp/services/managers/team-workflows-config.service.ts
+++ b/nodejs/src/cdp/services/managers/team-workflows-config.service.ts
@@ -19,8 +19,6 @@ export type TeamWorkflowsConfig = {
ses_tenant_provider_suspended: boolean
/** Trust tier that picks the team's hourly and daily workflow email caps. */
email_sending_tier: number
- /** Creation date of the team, so enforcement can be narrowed to teams created after a cutoff. */
- team_created_at: string | null
}
const DEFAULT_CONFIG: TeamWorkflowsConfig = {
@@ -29,12 +27,6 @@ const DEFAULT_CONFIG: TeamWorkflowsConfig = {
email_sending_suspended: false,
ses_tenant_provider_suspended: false,
email_sending_tier: 0,
- team_created_at: null,
-}
-
-export type TeamEmailSendingTier = {
- tier: number
- teamCreatedAt: string | null
}
/**
@@ -104,10 +96,10 @@ export class TeamWorkflowsConfigService {
* daily cap. Fails open with `null`: a lookup error must let the send through rather than
* throttle a legitimate customer, same stance as `isEmailSendingSuspended`.
*/
- public async getEmailSendingTier(teamId: number): Promise<TeamEmailSendingTier | null> {
+ public async getEmailSendingTier(teamId: number): Promise<number | null> {
try {
const config = await this.get(teamId)
- return { tier: config.email_sending_tier, teamCreatedAt: config.team_created_at }
+ return config.email_sending_tier
} catch (error) {
logger.error('[TeamWorkflowsConfig] Failed to read email sending tier', { teamId, error })
return null
@@ -115,8 +107,6 @@ export class TeamWorkflowsConfigService {
}
private async fetchConfigs(teamIds: string[]): Promise<Record<string, TeamWorkflowsConfig>> {
- // Joined to posthog_team rather than read separately: the tier cap can be scoped to teams
- // created after a cutoff, and the send path needs both values in the same cached entry.
const result = await this.postgres.query<{
team_id: number
capture_workflows_engagement_events: boolean
@@ -124,19 +114,16 @@ export class TeamWorkflowsConfigService {
email_sending_suspended: boolean
ses_tenant_provider_suspended: boolean
email_sending_tier: number
- team_created_at: string | null
}>(
PostgresUse.COMMON_READ,
// Only DISABLED blocks: ENABLED and REINSTATED both permit sending, and '' means the
// tenant state has never been synced for this team.
- `SELECT c.team_id, c.capture_workflows_engagement_events, c.email_tracking_consent_mode,
- c.email_sending_suspended_at IS NOT NULL AS email_sending_suspended,
- c.ses_tenant_sending_status = 'DISABLED' AS ses_tenant_provider_suspended,
- c.email_sending_tier,
- t.created_at AS team_created_at
- FROM workflows_teamworkflowsconfig c
- LEFT JOIN posthog_team t ON t.id = c.team_id
- WHERE c.team_id = ANY($1)`,
+ `SELECT team_id, capture_workflows_engagement_events, email_tracking_consent_mode,
+ email_sending_suspended_at IS NOT NULL AS email_sending_suspended,
+ ses_tenant_sending_status = 'DISABLED' AS ses_tenant_provider_suspended,
+ email_sending_tier
+ FROM workflows_teamworkflowsconfig
+ WHERE team_id = ANY($1)`,
[teamIds.map(Number)],
'fetch-team-workflows-configs'
)
@@ -152,7 +139,6 @@ export class TeamWorkflowsConfigService {
email_sending_suspended: row.email_sending_suspended,
ses_tenant_provider_suspended: row.ses_tenant_provider_suspended,
email_sending_tier: row.email_sending_tier ?? 0,
- team_created_at: row.team_created_at ?? null,
}
}
return configs
diff --git a/nodejs/src/cdp/services/messaging/email.service.ts b/nodejs/src/cdp/services/messaging/email.service.ts
index ad73d0f11f16..21829ffc137a 100644
--- a/nodejs/src/cdp/services/messaging/email.service.ts
+++ b/nodejs/src/cdp/services/messaging/email.service.ts
@@ -203,9 +203,6 @@ export interface EmailServiceConfig {
teamEmailCapMode?: TeamEmailCapMode
teamEmailTierHourlyCaps?: number[]
teamEmailTierDailyCaps?: number[]
- // ISO date. When set, only teams created on or after it are capped, so the caps can be turned
- // on for new projects without touching established ones. Empty means every team.
- teamEmailCapTeamsCreatedAfter?: string
}
/**
@@ -585,7 +582,7 @@ export class EmailService {
}
const teamTier = await this.teamWorkflowsConfigService.getEmailSendingTier(invocation.teamId)
- if (!teamTier || !this.teamEmailCapApplies(teamTier.teamCreatedAt)) {
+ if (teamTier === null) {
return null
}
@@ -599,7 +596,7 @@ export class EmailService {
if (topTier < 0) {
return null
}
- const tier = Math.min(Math.max(teamTier.tier, 0), topTier)
+ const tier = Math.min(Math.max(teamTier, 0), topTier)
const buckets = teamEmailCapBuckets(invocation.teamId, hourlyCaps[tier], dailyCaps[tier])
// Clamped to the smaller capacity: a send with more copies than a whole allowance could
@@ -652,25 +649,6 @@ export class EmailService {
return null
}
- /** Whether the cap applies to a team, given the optional created-after cutoff. */
- private teamEmailCapApplies(teamCreatedAt: string | null): boolean {
- const cutoff = this.sesConfig.teamEmailCapTeamsCreatedAfter?.trim()
- if (!cutoff) {
- return true
- }
- const cutoffMs = Date.parse(cutoff)
- if (Number.isNaN(cutoffMs)) {
- // An unparseable cutoff caps nobody. The cutoff exists to spare established teams, so
- // a bad value must fail towards leaving every team alone.
- return false
- }
- if (!teamCreatedAt) {
- return false
- }
- const createdMs = Date.parse(teamCreatedAt)
- return !Number.isNaN(createdMs) && createdMs >= cutoffMs
- }
-
// Returns a human-readable log string when any destination address is suppressed for the team,
// or null when the send should proceed. Scans to + cc + bcc — SES delivers to every list, so a
// suppressed address anywhere blocks the whole send. `cc` and `bcc` can be comma-separated
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index 48b0980f5496..85dbb7ac03d0 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -1047,14 +1047,10 @@ WORKFLOWS_EMAIL_TIER_AUTO_PAUSE_METRIC_NAMES: list[str] = get_list(
# "shadow" - tiers are computed and stored, and every send that a cap would have delayed is
# logged, but no send is delayed and no audience is rejected.
# "enforce" - caps apply.
-# The email worker has its own copy of these two, EMAIL_TEAM_SENDING_CAP_MODE and
-# EMAIL_TEAM_SENDING_CAP_TEAMS_CREATED_AFTER in nodejs/src/cdp/config.ts, because it never reads
-# Django settings. Set both sides together: this pair drives the batch audience cap and what the
-# workflows UI shows, and the worker's pair drives the send-time cap.
+# The email worker has its own copy, EMAIL_TEAM_SENDING_CAP_MODE in nodejs/src/cdp/config.ts,
+# because it never reads Django settings. Set both sides together: this one drives the batch
+# audience cap and what the workflows UI shows, and the worker's drives the send-time cap.
WORKFLOWS_EMAIL_TIER_MODE = get_from_env("WORKFLOWS_EMAIL_TIER_MODE", "off")
-# Narrows enforcement to teams created on or after this date (ISO 8601, e.g. "2026-01-01"), so the
-# caps can be turned on for new projects without touching established ones. Empty means all teams.
-WORKFLOWS_EMAIL_TIER_ENFORCE_TEAMS_CREATED_AFTER = get_from_env("WORKFLOWS_EMAIL_TIER_ENFORCE_TEAMS_CREATED_AFTER", "")
# Comma-separated list of org ids allowed to receive the Error Tracking weekly digest
# "*" for all, empty to disable feature
diff --git a/products/workflows/backend/utils/email_sending_tiers.py b/products/workflows/backend/utils/email_sending_tiers.py
index 6e0307760af6..3a1612f6c6fb 100644
--- a/products/workflows/backend/utils/email_sending_tiers.py
+++ b/products/workflows/backend/utils/email_sending_tiers.py
@@ -1,13 +1,10 @@
-from datetime import UTC, datetime
-from typing import Literal, Optional
+from typing import Literal
from django.conf import settings
-from django.utils.dateparse import parse_datetime
import structlog
from posthog.dataclasses import frozen
-from posthog.models.team import Team
from products.workflows.backend.models.team_workflows_config import TeamWorkflowsConfig
@@ -33,8 +30,7 @@ class TeamEmailSendingTier:
tier: int
pinned: bool
limits: EmailSendingTierLimits
- # False while the rollout mode is "off" or "shadow", or while enforcement is narrowed to teams
- # created after a cutoff this team predates. Callers must fall back to pre-tier behavior.
+ # False while the rollout mode is "off" or "shadow". Callers must fall back to pre-tier behavior.
enforced: bool
@@ -97,40 +93,8 @@ def get_email_sending_tier_limits(tier: int) -> EmailSendingTierLimits:
)
-def _enforcement_cutoff_raw() -> str:
- return str(settings.WORKFLOWS_EMAIL_TIER_ENFORCE_TEAMS_CREATED_AFTER or "").strip()
-
-
-def _enforcement_cutoff() -> Optional[datetime]:
- raw = _enforcement_cutoff_raw()
- if not raw:
- return None
- # Read on the send path, so a typo in the env var must not raise here.
- try:
- parsed = parse_datetime(raw)
- except ValueError:
- parsed = None
- if parsed is None:
- logger.warning("workflows_email_tier_cutoff_unparseable", value=raw)
- return None
- # A bare date ("2026-01-01") parses to a naive datetime, while the team creation dates it is
- # compared against are UTC-aware. Read a naive cutoff as UTC instead of raising on the compare.
- return parsed if parsed.tzinfo is not None else parsed.replace(tzinfo=UTC)
-
-
-def is_tier_enforced_for_team(team_created_at: Optional[datetime]) -> bool:
- if email_sending_tier_mode() != "enforce":
- return False
- cutoff = _enforcement_cutoff()
- if cutoff is None:
- # An empty cutoff enforces every team. A set but unparseable cutoff must not, because an
- # operator typo has to narrow enforcement rather than widen it to everyone. This matches
- # email_sending_tier_mode(), which reads an unrecognized value as "off", and the module's
- # rule that a config problem must never throttle a paying customer.
- return not _enforcement_cutoff_raw()
- # An unknown creation date reads as "not after the cutoff": the cutoff exists to spare
- # established teams, so an unresolvable team must land on the established side.
- return team_created_at is not None and team_created_at >= cutoff
+def is_tier_enforced() -> bool:
+ return email_sending_tier_mode() == "enforce"
def resolve_team_email_sending_tier(team_id: int) -> TeamEmailSendingTier:
@@ -157,43 +121,31 @@ def resolve_team_email_sending_tier(team_id: int) -> TeamEmailSendingTier:
def _resolve_team_email_sending_tier(team_id: int, top_tier: int) -> TeamEmailSendingTier:
- row = (
- TeamWorkflowsConfig.objects.filter(team_id=team_id)
- .values("email_sending_tier", "email_sending_tier_pinned", "team__created_at")
- .first()
- )
-
if team_id in settings.HOGFLOW_BATCH_TRIGGER_ELEVATED_TEAM_IDS:
# The pre-tier allowlist keeps working as a staff pin at the top tier.
return TeamEmailSendingTier(
tier=top_tier,
pinned=True,
limits=get_email_sending_tier_limits(top_tier),
- enforced=is_tier_enforced_for_team(row["team__created_at"] if row else _team_created_at(team_id)),
+ enforced=is_tier_enforced(),
)
+ row = (
+ TeamWorkflowsConfig.objects.filter(team_id=team_id)
+ .values("email_sending_tier", "email_sending_tier_pinned")
+ .first()
+ )
if row is None:
- # No row means the team never touched a workflows setting, so it starts at tier 0. Reading
- # the creation date still matters: enforcement can be narrowed to teams created after a
- # cutoff, and a team without a row can sit on either side of it.
+ # No row means the team never touched a workflows setting, so it starts at tier 0.
tier = MIN_EMAIL_SENDING_TIER
pinned = False
- created_at = _team_created_at(team_id)
else:
tier = row["email_sending_tier"]
pinned = row["email_sending_tier_pinned"]
- created_at = row["team__created_at"]
return TeamEmailSendingTier(
tier=tier,
pinned=pinned,
limits=get_email_sending_tier_limits(tier),
- enforced=is_tier_enforced_for_team(created_at),
+ enforced=is_tier_enforced(),
)
-
-
-def _team_created_at(team_id: int) -> Optional[datetime]:
- if _enforcement_cutoff() is None:
- # Without a cutoff the date changes nothing, so skip the query.
- return None
- return Team.objects.filter(id=team_id).values_list("created_at", flat=True).first()
diff --git a/products/workflows/backend/utils/test_batch_trigger_limit.py b/products/workflows/backend/utils/test_batch_trigger_limit.py
index 5bb06288f83b..965a7cdc5517 100644
--- a/products/workflows/backend/utils/test_batch_trigger_limit.py
+++ b/products/workflows/backend/utils/test_batch_trigger_limit.py
@@ -77,35 +77,11 @@ class TestTieredHogflowBatchTriggerLimit(BaseTest):
with override_settings(HOGFLOW_BATCH_TRIGGER_ELEVATED_TEAM_IDS={self.team.id}):
assert get_hogflow_batch_trigger_limit(self.team.id) == 50000
- @override_settings(
- WORKFLOWS_EMAIL_TIER_MODE="enforce",
- WORKFLOWS_EMAIL_TIER_ENFORCE_TEAMS_CREATED_AFTER="2099-01-01",
- )
- def test_team_created_before_the_cutoff_keeps_the_flat_limit(self) -> None:
- TeamWorkflowsConfig.objects.update_or_create(team=self.team, defaults={"email_sending_tier": 0})
- assert get_hogflow_batch_trigger_limit(self.team.id) == 5000
-
- @override_settings(
- WORKFLOWS_EMAIL_TIER_MODE="enforce",
- WORKFLOWS_EMAIL_TIER_ENFORCE_TEAMS_CREATED_AFTER="not-a-date",
- )
- def test_unparseable_cutoff_does_not_enforce_globally(self) -> None:
- # A typo in the cutoff must fail open. It cannot silently widen enforcement to every team,
- # so an unparseable value leaves the team on the flat ceiling instead of the tier-0 cap.
- TeamWorkflowsConfig.objects.update_or_create(team=self.team, defaults={"email_sending_tier": 0})
- assert get_hogflow_batch_trigger_limit(self.team.id) == 5000
-
- @override_settings(
- WORKFLOWS_EMAIL_TIER_MODE="enforce",
- WORKFLOWS_EMAIL_TIER_ENFORCE_TEAMS_CREATED_AFTER="2020-01-01",
- )
+ @override_settings(WORKFLOWS_EMAIL_TIER_MODE="enforce")
def test_a_database_error_during_resolution_fails_open(self) -> None:
- # The creation-date lookup runs outside the first config query, so the fail-open guard must
- # cover the whole resolution: a database blip on the send path returns the flat limit
- # instead of raising.
- TeamWorkflowsConfig.objects.filter(team=self.team).delete()
+ # A database blip on the send path returns the flat limit instead of raising.
with patch(
- "products.workflows.backend.utils.email_sending_tiers.Team.objects.filter",
+ "products.workflows.backend.utils.email_sending_tiers.TeamWorkflowsConfig.objects.filter",
side_effect=Exception("db down"),
):
assert get_hogflow_batch_trigger_limit(self.team.id) == 5000