Commit ffc0309
authored
fix(start): lazy-init languages on /start to unblock cold-start orphans (#222)
Sega (#370728472) hit /start, immediately got "memes ended". Root cause:
no rows in user_language for him → recommendations query filters every
candidate out → cold start surfaces the empty-feed message.
How he ended up there: he registered on 2026-04-01 with deep_link
'kitchen'. The kitchen branch in handle_start returns BEFORE any
init_user_languages_from_tg_user call:
if deep_link == "kitchen":
return await handle_show_kitchen(update, context)
The wrapped + main "if created" branches both call init; kitchen
silently skipped it. Six new users in the last 30 days (4 via 'kitchen',
2 via deep_link=None) ended up the same way — all backfilled by hand
just now.
Fix: hoist a single idempotent check above the deep_link branching:
if not await get_user_languages(user_id):
await init_user_languages_from_tg_user(update.effective_user)
This covers every branch (current + future deep_links) and self-heals
any historical orphan the next time they /start. Removed the per-branch
init calls in wrapped + new-user paths since the new check supersedes
them. Idempotent guarantee: add_user_languages uses ON CONFLICT DO NOTHING.
Note on extent: 893 historical orphans exist (mostly pre-init code),
but only 6 were active in the last 30d / 3 in the last 7d — the bug
was not blocking the main onboarding funnel (38/38 new users in last
7d had languages). It was a long-tail correctness issue that bit any
share-link / deep-link path that returned early.1 parent 6df40d3 commit ffc0309
1 file changed
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
105 | 114 | | |
106 | 115 | | |
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
110 | 119 | | |
111 | | - | |
112 | | - | |
113 | 120 | | |
114 | 121 | | |
115 | 122 | | |
116 | | - | |
117 | 123 | | |
118 | 124 | | |
119 | 125 | | |
| |||
0 commit comments