mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-12-04 00:56:43 +09:00
main
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
70bdd0e693 |
fix(alerts): start-review 409, per-cause crash patterns, one alert per job failure (v0.290.1) (#1243)
Section 1 of the 2026-11-03 #alerts triage handoff: a stale push on a
finished song got a 500, and the error monitor could stay silent on a
new crash.
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1566980744448843886
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1566980746394996879
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1566980747905073224
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1565697725280948294
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1565803187334815775
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1565818418072916110
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1566225593354420226
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1566256141074169987
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1567207141994135654
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1567252495535841386
Alert:
https://discord.com/channels/1198691101943541770/1265517528608669707/1567252497620537415
## What changed
**1a. start-review:** a job not in review gets 409
(`jobs.jobNotInReviewState`) with no transition attempted. Losing the
auto-approver race is a 409 too. `correction-data` has the same race,
and its `except Exception` turned it into a 500; it now returns 409
(`except HTTPException: raise` added). Its status gate still returns
400, as before.
**1b. Crash patterns:** `Exception in ASGI application` and
`request_audit_error` become `Unhandled exception: <Type: message>`,
read from the entry's `exception` field. The handoff's suspicion is
confirmed in `upsert_pattern`: an existing `new` pattern returns
`is_new=False`, so a second, different crash stayed silent. Both log
lines of one crash now share one pattern. The path and method go in the
sample only.
I read the line after the last frame rather than the traceback's last
line. pydantic's last line is a docs link shared by every failure, and
group tracebacks end in a separator.
**1c. One alert per failure:**
- YouTube ids are normalized out of signatures, which also fixes the
false "first time" line in `ops_alerts`.
- `Job <id> failed` (both call sites in `job_manager`) logs WARNING,
since the status write sends the job-failed alert.
- `URL download failed:` is ignored in the monitor, not demoted, because
`file_upload.py` belongs to the section 4 PR.
- `[job:<id>] Download failed` logs WARNING for the expected
`DownloadError`/`FlacfetchServiceError` types. This wasn't named in the
handoff, but it is the same duplicate on the audio-search path.
Unexpected exceptions there stay ERROR with a traceback.
**1d. Suppressions and demotions:**
- Zalo's `zaloJSV2 is not defined`: dropped at `/api/client-errors`,
only with a Zalo UA.
- `python -c` experiments on `audio-separation-job`: ignored, using the
handoff's regex.
- Spotify 403 on `/lyrics`: WARNING with `response.text[:200]`. 401 on
`/lyrics` and 401/403 on `/search` stay ERROR.
- Dropbox token probe: WARNING. A rejected refresh used to log nothing,
so it now logs ERROR, as does having no refresh credentials.
- decide-search health aborts: this was a small change. `should_ignore`
takes an optional `request_url` and matches the exact path
`/api/search/health`.
**1e. Cold start:** `anyio._backends._asyncio` is added to
`_LAZY_ROUTE_IMPORTS`. The prod stack from 10-30 confirms the stall was
in that import. Lifespan also sends one `/api/health` request through
the app in a worker thread, bounded by the existing 30s timeout and
best-effort.
## Testing
- TDD: new tests failed first, then passed.
- Affected suites: 826 passed.
- `backend/tests` (excluding `backend/tests/emulator`): 7088 passed, 8
failed, 29 skipped. All 8 are in `test_emulator_integration.py`, and
that file also shows 8 failures at the base commit
|
||
|
|
5d56ee9069 |
fix(frontend): stop reporting opaque cross-origin "Script error." (v0.238.6) (#1050)
## Summary The error monitor keeps alerting on a frontend pattern `@https://gen.nomadkaraoke.com/` with sample `Error: Script error.` (iOS Safari, 4 occurrences since June). That's the browser's opaque cross-origin error: a script from another origin (a third-party tag, in-app browser or extension injection) threw. The browser hides everything, so there's no error object, filename or line. Our `window.onerror` handler wrapped it in `new Error(event.message)`, so the only "stack" frame (`63bfc60a…js:6:874`) is our own handler. There's nothing actionable in these reports. ## Changes - `frontend/lib/client-error-setup.ts`: new exported `isOpaqueCrossOriginError(event)`. The window `error` listener returns early when `event.error == null` and the message is `Script error.`. - `backend/services/error_monitor/frontend_ingestion.py` + `backend/api/routes/client_errors.py`: `is_opaque_script_error()` drops bare `Script error.` / `Error: Script error.` reports at ingestion. They're accepted (202) but not persisted, the same way the bot filter works. This also stops older cached bundles from alerting. - `docs/ARCHITECTURE.md`: a note on the crash-report noise filters. - Version 0.238.5 → 0.238.6. ## Testing - New Jest `lib/__tests__/client-error-setup.test.ts`: tests the predicate; an opaque event is not reported; a real error is still reported. Full Jest: 1342 passed. - Backend: parametrized API tests (dropped vs "Script error in …" still persisted) and unit tests for the predicate. `tests/unit` passed (1834), and `backend/tests` without the emulator passed (4591). Emulator tests are left to CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Opaque cross-origin “Script error” events without an error object and location details are no longer recorded. Other client errors, including script errors with location details or different messages, continue through the reporting flow. * Matching is case- and whitespace-tolerant and allows an optional trailing period. * **Documentation** * Updated Error Monitor guidance to describe which browser and server-side errors are ignored. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
d6361ca7ad |
fix(error-monitor): stop transient-capacity + bot crashes from paging (#897)
## Why Two alert-channel noise sources surfaced during the flacfetch download incident. Neither was a real production problem, but both page — so we fix the **monitor's signal quality** rather than mute them. ### 1. Transient encoding-worker capacity retries `[job:…] Encoding worker start failed, aborting retries: VM … 503 — SERVICE UNAVAILABLE` is a transient GCP zonal-capacity event. `render_video_worker` catches `EncodingWorkerStartError` and **parks the job for auto-retry** (`_park_job_for_capacity_retry`) — the job is *not* lost, and a genuine give-up fails the job via a separate ERROR. Added a `known_issues` suppression **scoped to the transient signal only** (503 / `SERVICE UNAVAILABLE` or a capacity code: `ZONE_RESOURCE_POOL_EXHAUSTED` / `STOCKOUT` / `QUOTA_EXCEEDED`). A non-transient `EncodingWorkerStartError` (other/unknown code) shares the prefix but **still pages**. ### 2. One incident → N alerts (normalizer gap) The same failure produced *two* alerts (same job, two preview-render IDs). `preview_<jobid>_<renderid>` is underscore-joined, and the generic hex normalizer is `\b`-anchored (`_` is a word char), so every preview render hashed to a distinct "new pattern." Added a normalizer rule that collapses `preview_<hex>_<hex>` → `preview_<ID>`. ### 3. Bot/crawler browser crashes `NotFoundError: removeChild` on `/en/r/` came from **bingbot** running headless Chrome — a React DOM-reconciliation error no real user hits (0 real-user occurrences in 7d). Reports from bot/crawler user-agents are now dropped at the `/client-errors` ingestion edge (still `202` so the client won't retry), instead of being persisted/alerted. ## Tests - `known_issues`: transient 503 **and** capacity-code variants suppressed; non-transient start failure + genuine job failure still alert. - `normalizer`: preview-ID collapse; two renders of one job → same hash. - `is_bot_user_agent`: crawler matrix true, real-browser/empty/None false. - API: a bingbot report is accepted (`202`, `is_new=false`) but **not upserted**. `133 passed`. Local CodeRabbit review completed and its two findings (scope the capacity regex; sanitize the logged bot URL) were addressed; a confirming re-review was blocked by the free-tier rate limit, so leaving the bot review on. ## Notes The actual outage in this incident (daily E2E download failure) was a **flacfetch** bug, fixed + deployed separately (flacfetch #36). This PR only removes the alert noise those investigations surfaced. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Bot and crawler error reports are acknowledged without being persisted or triggering alerts. - Transient encoding-worker capacity failures are filtered as retryable infrastructure noise. - Preview render job identifiers are normalized consistently for improved error grouping. - **Maintenance** - Updated the application version to 0.192.2. - Expanded validation for bot detection, error filtering, and preview error normalization. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
6445864534 |
feat: frontend crash reporting → Discord alerts + auto cache bust (#725)
@coderabbitai ignore ## Summary Gives us long-term peace of mind that frontend errors never reach users silently. Every client-side crash is captured, shown to the user with useful debug info, reported to the backend, alerted via the existing Discord error channel, and — critically — after a fix ships, affected users pick it up automatically. ## What this does - **Backend endpoint** `POST /api/client-errors` — normalises inbound reports and upserts into the same `error_patterns` Firestore collection the backend already uses. No new Discord wiring needed: `service="frontend"` patterns flow through the existing error-monitor Cloud Run Job → Discord pipeline. - **Three capture layers on the frontend**: - Global `window.onerror` + `unhandledrejection` listeners (mounted once per tab via `ClientErrorInit` in the locale layout) - Next.js App Router `error.tsx` (per-locale) + `global-error.tsx` (last-resort root) - React `CrashReportBoundary` wrapping `LyricsReviewWrapper` + `InstrumentalReviewWrapper` so a crash there renders in place rather than white-screening the route - **User-facing `CrashReport` card** — shows error name/message + collapsible stack + debug info + build SHA; auto-sends on mount (catches bugs in the wild without user action); has Copy / Send again / Try again / Back buttons. - **Version-aware cache busting** so the next bug I fix actually reaches affected users: - `public/version.json` emitted at build time via a new `prebuild` hook. - `isStale()` compares the compiled `NEXT_PUBLIC_COMMIT_SHA` against the live `/version.json`. - `ChunkLoadError` in the global handlers triggers a hard reload (unregisters SWs, clears caches, navigates with `?_v=<sha>` query-string) behind a 60 s circuit breaker to prevent reload loops. - `CrashReport` shows a prominent "A newer version is available — Update now" banner when stale; demotes "Try again" to secondary in that case. - Ambient 10-minute poll dispatches a `karaoke:stale-version` CustomEvent (no auto-reload ambient — only on crash). - **Admin `/admin/_crash-test` page** — three buttons that fire async throw / unhandled rejection / render-time throw, for post-deploy pipeline verification. - **Rate limiting** on the endpoint: 60/min per IP sliding window, plus pattern-hash dedup collapsing viral bugs to a single pattern. - **Privacy**: URL query strings + fragments stripped; user email only sent if authenticated; no cookies / localStorage / form-value capture. - **i18n**: `crashReport` namespace in `en.json` translated into all 32 locales. Reuses existing env var `NEXT_PUBLIC_COMMIT_SHA` — no new build config. ## Review & verification - 49 Jest suites / 800 tests pass (`make test`). - New unit tests: `crash-reporter.test.ts`, `CrashReport.test.tsx`, `CrashReportBoundary.test.tsx`, `version-check.test.ts`, `test_frontend_ingestion.py`, `test_client_errors.py` — all green. - Implemented task-by-task via subagent-driven workflow with spec + code quality review per task (see `docs/archive/2026-04-19-frontend-crash-reporting-plan.md`). - E2E Playwright test deferred — the admin crash-test page covers manual post-deploy verification. ## Test plan - [ ] Deploy to prod. - [ ] Visit `https://gen.nomadkaraoke.com/admin/_crash-test` as admin; click each of the three buttons. - [ ] Confirm a Discord alert arrives in the error channel (may take up to ~15 min per the monitor Cloud Run schedule). - [ ] Verify Firestore `error_patterns` contains 3 new docs with `service="frontend"`. - [ ] In a separate browser session already open to the app, simulate a stale-bundle scenario (edit `public/version.json` on the CDN, or use an older tab after a new deploy) — confirm `CrashReport` shows the "Update now" banner if an error is thrown. - [ ] Test the original Firefox Android bug (if it reproduces) and verify the crash now lands in Discord with a usable stack trace. ## Follow-ups - Source-map upload for readable production stacks (`Task 15` in the plan). - Consider forwarding the `source` payload field into `PatternData.sample_message` if finer-grained Discord triage (`window.onerror` vs `unhandledrejection` vs boundary) becomes valuable. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |