From 0c1aa16469578744d6fef5da0873c081bdded34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrew=20Beveridge=20=E2=98=84=EF=B8=8F?= Date: Thu, 15 Oct 2026 12:44:43 -0400 Subject: [PATCH] Turn on conversion emails + fix doubled signature on credit-denied email (v0.273.3) (#1160) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - **Conversion emails go live.** Andrew approved the copy, the 25% offer, the timings and the 612 Joan St postal address. Adds `CONVERSION_EMAILS_ENABLED=true,REVIEW_LAST_CHANCE_ENABLED=true,CONVERSION_OFFER_PERCENT=25` to the backend `--set-env-vars` in ci.yml (feature shipped dark in #1156). - **Doubled signature fix.** The "About your Nomad Karaoke free credits" (credit-denied) email appended `_get_email_signature()` itself and also got it from the shared footer, so it showed twice. I audited all 22 `send_*` emails by rendering each one; this was the only duplicate. - New regression test: renders every `EmailService.send_*` and asserts the signature appears exactly once. It fails on main with `send_credit_denied_email: 2`. ## Testing - `make test` green (backend 2054 + 6071 + 150, frontend 1692). - Local CodeRabbit review: no findings. @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_019KuzHAU4rxkv8JfD8NmHTN --------- Co-authored-by: Claude Opus 5.5 --- .github/workflows/ci.yml | 2 +- backend/services/email_service.py | 2 - backend/tests/test_email_service.py | 68 +++++++++++++++++++++++++++++ docs/CONVERSION-EMAILS.md | 2 +- pyproject.toml | 2 +- 5 files changed, 71 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef6992a6..6a768a99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2061,7 +2061,7 @@ jobs: --max-instances 20 \ --min-instances 0 \ --clear-vpc-connector \ - --set-env-vars "GOOGLE_CLOUD_PROJECT=${{ env.PROJECT_ID }},GCS_BUCKET_NAME=karaoke-gen-storage-${{ env.PROJECT_ID }},FIRESTORE_COLLECTION=jobs,ENVIRONMENT=production,KARAOKE_GEN_VERSION=$VERSION,DEFAULT_DROPBOX_PATH=/MediaUnsynced/Karaoke/Tracks-Organized,DEFAULT_GDRIVE_FOLDER_ID=1laRKAyxo0v817SstfM5XkpbWiNKNAMSX,ENABLE_CLOUD_TASKS=true,CLOUD_RUN_SERVICE_URL=https://api.nomadkaraoke.com,GCP_REGION=us-central1,DEFAULT_ENABLE_YOUTUBE_UPLOAD=true,DEFAULT_BRAND_PREFIX=NOMAD,DEFAULT_PRIVATE_DROPBOX_PATH=/MediaUnsynced/Karaoke/Tracks-NonPublished,DEFAULT_PRIVATE_BRAND_PREFIX=NOMADNP,USE_GCE_ENCODING=true,USE_GCE_PREVIEW_ENCODING=true,ENABLE_PUSH_NOTIFICATIONS=true,USE_CLOUD_RUN_JOBS_FOR_VIDEO=true,USE_CLOUD_RUN_JOBS_FOR_RENDER=true,EMAIL_PROVIDER=postmark,AUTO_CORRECT_MODEL=claude-opus-5-5,AUTO_CORRECT_COMPARE_MODELS=claude-opus-5-5;gemini-3.8-flash,AUTO_CORRECT_PROACTIVE_ENABLED=true,AUTO_APPROVAL_BACKING_KEEP_ENABLED=true,COMMUNITY_DAILY_PICK_ENABLED=true,STORAGE_RETENTION_DRY_RUN=false,STORAGE_RETENTION_MAX_JOBS_PER_RUN=50,EDGE_AUTH_MODE=enforce,COMMIT_SHA=${{ steps.build-meta.outputs.sha }},PR_NUMBER=${{ steps.build-meta.outputs.pr_number }},PR_TITLE=${{ steps.build-meta.outputs.pr_title }}" \ + --set-env-vars "GOOGLE_CLOUD_PROJECT=${{ env.PROJECT_ID }},GCS_BUCKET_NAME=karaoke-gen-storage-${{ env.PROJECT_ID }},FIRESTORE_COLLECTION=jobs,ENVIRONMENT=production,KARAOKE_GEN_VERSION=$VERSION,DEFAULT_DROPBOX_PATH=/MediaUnsynced/Karaoke/Tracks-Organized,DEFAULT_GDRIVE_FOLDER_ID=1laRKAyxo0v817SstfM5XkpbWiNKNAMSX,ENABLE_CLOUD_TASKS=true,CLOUD_RUN_SERVICE_URL=https://api.nomadkaraoke.com,GCP_REGION=us-central1,DEFAULT_ENABLE_YOUTUBE_UPLOAD=true,DEFAULT_BRAND_PREFIX=NOMAD,DEFAULT_PRIVATE_DROPBOX_PATH=/MediaUnsynced/Karaoke/Tracks-NonPublished,DEFAULT_PRIVATE_BRAND_PREFIX=NOMADNP,USE_GCE_ENCODING=true,USE_GCE_PREVIEW_ENCODING=true,ENABLE_PUSH_NOTIFICATIONS=true,USE_CLOUD_RUN_JOBS_FOR_VIDEO=true,USE_CLOUD_RUN_JOBS_FOR_RENDER=true,EMAIL_PROVIDER=postmark,AUTO_CORRECT_MODEL=claude-opus-5-5,AUTO_CORRECT_COMPARE_MODELS=claude-opus-5-5;gemini-3.8-flash,AUTO_CORRECT_PROACTIVE_ENABLED=true,AUTO_APPROVAL_BACKING_KEEP_ENABLED=true,COMMUNITY_DAILY_PICK_ENABLED=true,STORAGE_RETENTION_DRY_RUN=false,STORAGE_RETENTION_MAX_JOBS_PER_RUN=50,CONVERSION_EMAILS_ENABLED=true,REVIEW_LAST_CHANCE_ENABLED=true,CONVERSION_OFFER_PERCENT=25,EDGE_AUTH_MODE=enforce,COMMIT_SHA=${{ steps.build-meta.outputs.sha }},PR_NUMBER=${{ steps.build-meta.outputs.pr_number }},PR_TITLE=${{ steps.build-meta.outputs.pr_title }}" \ --set-secrets "ANTHROPIC_API_KEY=anthropic-api-key:latest,GEMINI_API_KEY=gemini-api-key:latest,AUDIOSHAKE_API_TOKEN=audioshake-api-key:latest,GENIUS_API_TOKEN=genius-api-key:latest,SPOTIFY_COOKIE_SP_DC=spotify-cookie:latest,RAPIDAPI_KEY=rapidapi-key:latest,DEFAULT_DISCORD_WEBHOOK_URL=discord-releases-webhook:latest,ADMIN_TOKENS=admin-tokens:latest,RED_API_KEY=red-api-key:latest,RED_API_URL=red-api-url:latest,OPS_API_KEY=ops-api-key:latest,OPS_API_URL=ops-api-url:latest,FLACFETCH_API_URL=flacfetch-api-url:latest,FLACFETCH_API_KEY=flacfetch-api-key:latest,POSTMARK_SERVER_TOKEN=postmark-server-token:latest,STRIPE_SECRET_KEY=stripe-secret-key:latest,STRIPE_WEBHOOK_SECRET=stripe-webhook-secret:latest,LANGFUSE_PUBLIC_KEY=langfuse-public-key:latest,LANGFUSE_SECRET_KEY=langfuse-secret-key:latest,LANGFUSE_HOST=langfuse-host:latest,ENCODING_WORKER_URL=encoding-worker-url:latest,ENCODING_WORKER_API_KEY=encoding-worker-api-key:latest,ENCODING_WORKER_FALLBACK_VMS=encoding-worker-fallback-vms:latest,VAPID_PUBLIC_KEY=vapid-public-key:latest,VAPID_PRIVATE_KEY=vapid-private-key:latest,E2E_BYPASS_KEY=e2e-bypass-key:latest,GDRIVE_VALIDATOR_URL=gdrive-validator-url:latest,EDGE_ORIGIN_SECRET=edge-origin-secret:latest,KARAOKEHUNT_FORWARDER_SECRET=karaokehunt-forwarder-secret:latest,KJBOX_PARTNER_SECRET=kjbox-partner-secret:latest" # R3/R4 — smoke the tagged candidate revision BEFORE it serves any traffic. diff --git a/backend/services/email_service.py b/backend/services/email_service.py index 95b7dfdd..ff8c656d 100644 --- a/backend/services/email_service.py +++ b/backend/services/email_service.py @@ -2909,8 +2909,6 @@ If the user looks legitimate, grant them credits from their admin page.

{t(locale, "emails.creditDenied.costNote")}

- - {self._get_email_signature()} """ text_content = f"""{t(locale, "emails.creditDenied.greeting")} diff --git a/backend/tests/test_email_service.py b/backend/tests/test_email_service.py index 67c4553b..98bdbad5 100644 --- a/backend/tests/test_email_service.py +++ b/backend/tests/test_email_service.py @@ -1064,3 +1064,71 @@ class TestMadeForYouAdminNotification: ) assert result is False + + +class TestEverySendHasOneSignature: + """Every customer email gets the signature exactly once, via the shared footer. + + Regression: the credit-denied ("About your Nomad Karaoke free credits") email + appended the signature itself AND got it from _build_email_html, so it showed twice. + """ + + @staticmethod + def _sample(name, param): + import inspect + + n = name.lower() + if param.annotation is int or any(k in n for k in ("credits", "count", "hours", "percent")): + return 3 + if param.annotation is bool: + return False + if "email" in n: + return "user@example.com" + if "locale" in n: + return "en" + if "url" in n or "link" in n: + return "https://example.com/x" + if param.annotation is dict or "details" in n: + return {} + if param.annotation is list: + return [] + assert param.default is inspect.Parameter.empty + return "Sample" + + def _send_methods(self): + import inspect + + return [ + (name, fn) + for name, fn in inspect.getmembers(EmailService, inspect.isfunction) + if name.startswith("send_") and name != "send_email" + ] + + def test_send_methods_discovered(self): + names = {n for n, _ in self._send_methods()} + assert {"send_credit_denied_email", "send_welcome_email", "send_job_completion"} <= names + + def test_signature_appears_exactly_once(self): + import inspect + + signature_marker = "+1 (803) 636-3267" + service = EmailService() + assert service._get_email_signature().count(signature_marker) == 1 + failures = [] + for name, fn in self._send_methods(): + service.provider = Mock() + service.provider.send_email.return_value = True + kwargs = { + pn: self._sample(pn, p) + for pn, p in list(inspect.signature(fn).parameters.items())[1:] + if p.default is inspect.Parameter.empty + } + with patch.object(EmailService, "_record_sent_email"): + fn(service, **kwargs) + if not service.provider.send_email.called: + continue + html_content = service.provider.send_email.call_args.kwargs["html_content"] + count = html_content.count(signature_marker) + if count != 1: + failures.append(f"{name}: {count}") + assert not failures, f"signature count != 1 in: {failures}" diff --git a/docs/CONVERSION-EMAILS.md b/docs/CONVERSION-EMAILS.md index 005578e5..5c4b3337 100644 --- a/docs/CONVERSION-EMAILS.md +++ b/docs/CONVERSION-EMAILS.md @@ -8,7 +8,7 @@ Added 2026-10 for BACKLOG Frog #2 ("plug the gen revenue leaks"). Funnel context | **E2** "Your N% off ends in N hours" | inside the last `CONVERSION_E2_HOURS_BEFORE_EXPIRY` (8h) of the offer, only if still unpaid | Postmark `broadcast` | `CONVERSION_EMAILS_ENABLED` | | **R2** "N hours left to finish your karaoke video" | 42h into lyrics review (expiry is 48h; the existing reminder fires at 24h) | `outbound` (transactional) | `REVIEW_LAST_CHANCE_ENABLED` | -All of these are **off by default** and are switched on via Cloud Run env once Andrew approves the copy. +All of these are **off by default** in code. Andrew approved the copy, 25%, the timings and the postal address on 2026-10-15, and they are switched **on in production** via the Cloud Run env in `.github/workflows/ci.yml` (v0.273.3). ## How it works - `backend/services/conversion_emails.py`: diff --git a/pyproject.toml b/pyproject.toml index a984941e..5eeadc72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "karaoke-gen" -version = "0.273.2" +version = "0.273.3" description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens." authors = ["Andrew Beveridge "] license = "MIT"