mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
## Summary Motivated by external contributor Martín (netux) asking "is there an easy way to run the full backend without GCS?" — he couldn't test PR #895's backend changes locally. This PR makes the whole backend runnable locally against emulators with **zero GCP credentials and zero paid API keys**. ### What was broken for contributors - Workers migrated to Cloud Run Jobs for prod robustness (audio-download, audio-separation, lyrics-transcription, bulk-search) silently bypassed the direct-HTTP dev mode → local jobs stalled at PENDING forever - Signed URL generation called `google.auth.default()` → crashed with no credentials (review audio, downloads, theme previews, upload URLs) - Magic-link login 503'd locally (console email provider counted as "not configured") - Fresh emulator had no default theme → every job create returned 422 - `docs/DEVELOPMENT.md` told people to `cp .env.example .env` but the file didn't exist — and nothing loaded `.env` anyway - `run-backend-local.sh` defaulted to the production GCP project ### Changes - **worker_service**: CRJ-based workers run as local subprocesses (`python -m backend.workers.X --job-id Y`, exact CRJ parity) when `ENABLE_CLOUD_TASKS=false` **and** not `is_production()` (regression-tested both ways) - **storage_service**: signed URLs → plain fake-gcs-server URLs when `STORAGE_EMULATOR_HOST` set (GET via JSON API download path; PUT via unvalidated-signature path, enabled by `-public-host` on the emulator) - **users route**: magic-link 503 only in production; dev prints the link to the console - **file_upload bugfix**: a theme with style params but no asset files never got `style_params_gcs_path` written (empty-dict falsiness in `elif theme_style_assets:`) — surfaced by the minimal seed theme, latent in prod - **scripts/seed-local-data.py** (new): creates bucket + default theme; wired into `run-backend-local.sh --with-emulators`, which now uses `test-project` - **config**: `load_dotenv()` so `.env` actually works; new root `.env.example` - **CONTRIBUTING.md** (new): no-credentials quickstart; README + DEVELOPMENT.md link to it ### Verified end-to-end locally (no GCP credentials) Upload job → local audio separation (real models) → transcription → screens → `awaiting_review`; review endpoints all working including `/api/review/{job}/audio/vocals` (the PR #895 endpoint) and 302 → emulator audio URLs. Magic-link login round-trip via console link. ### Tests - 224 tests across affected files pass; full backend unit suite: 3969 passed - `backend/tests/test_emulator_integration.py` has 8 pre-existing failures that reproduce identically on unmodified `main` locally (broken theme-service mock in that file) — unrelated to this PR - New tests: dev-mode subprocess dispatch (audio + bulk-search), prod-mode never-Popen guard, emulator URL generation (GET + PUT) @coderabbitai ignore --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
64 lines
2.1 KiB
TOML
64 lines
2.1 KiB
TOML
# Nomad Karaoke shared gitleaks config.
|
|
# Extends the default ruleset with one custom rule for Discord webhooks
|
|
# and an allowlist covering known false-positive paths.
|
|
|
|
title = "Nomad Karaoke"
|
|
|
|
[extend]
|
|
useDefault = true
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Custom rules
|
|
# ---------------------------------------------------------------------------
|
|
|
|
[[rules]]
|
|
id = "discord-webhook-url"
|
|
description = "Discord webhook URL (token embedded in URL)"
|
|
regex = '''https://(?:discord|discordapp)\.com/api/webhooks/\d{17,20}/[A-Za-z0-9_-]{60,}'''
|
|
tags = ["discord", "webhook", "secret"]
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Global allowlist
|
|
# ---------------------------------------------------------------------------
|
|
|
|
[allowlist]
|
|
description = "Paths and patterns that are known false positives"
|
|
|
|
paths = [
|
|
'''(?i)\.(jpg|jpeg|png|gif|bmp|svg|webp|pdf|ico|mp3|mp4|wav|flac|m4a)$''',
|
|
'''(^|/)(package-lock\.json|yarn\.lock|pnpm-lock\.yaml|poetry\.lock|Podfile\.lock|Cargo\.lock|go\.sum|composer\.lock|Gemfile\.lock|uv\.lock)$''',
|
|
'''(^|/)node_modules/''',
|
|
'''(^|/)vendor/''',
|
|
'''(^|/)wp-content/''',
|
|
'''(^|/)\.dart_tool/''',
|
|
'''(^|/)\.venv/''',
|
|
'''(^|/)\.next/''',
|
|
'''(^|/)build/''',
|
|
'''(^|/)dist/''',
|
|
'''(^|/)\.flutter-plugins''',
|
|
'''(^|/)test[-_]?fixtures?/''',
|
|
'''(^|/)tests?/.*conftest\.py$''',
|
|
'''(^|/)tests?/.*test_[^/]+\.py$''',
|
|
'''(^|/)tests?/.*_test\.py$''',
|
|
'''(^|/).*\.(test|spec)\.(js|mjs|cjs|ts|tsx|jsx)$''',
|
|
'''(^|/).*\.test\.local\.(js|mjs|cjs|ts|tsx|jsx|py)$''',
|
|
'''(^|/).*\.local\.(js|mjs|cjs|ts|tsx|jsx|py)$''',
|
|
]
|
|
|
|
regexes = [
|
|
# Explicit placeholder patterns
|
|
'''YOUR_[A-Z_]{2,}''',
|
|
'''EXAMPLE_[A-Z_]{2,}''',
|
|
'''PLACEHOLDER_[A-Z_]{2,}''',
|
|
'''CHANGE[_-]?ME''',
|
|
'''<[A-Z_]{2,}>''',
|
|
'''\$\{[A-Z_]{2,}\}''',
|
|
|
|
# Firebase / GCP client API keys — public by design (identify the project,
|
|
# access is gated by Firebase Security Rules).
|
|
'''AIzaSy[A-Za-z0-9_-]{33}''',
|
|
|
|
# Documented local-development placeholder token (CONTRIBUTING.md, dev scripts)
|
|
'''local-dev-token''',
|
|
]
|