managarten/picture/process-jobs-fix.md
Till-JS c712a2504a feat: integrate uload and picture, unify package naming
- Add uload project with apps/web structure
  - Reorganize from flat to monorepo structure
  - Remove PocketBase binary and local data
  - Update to pnpm and @uload/web namespace

- Add picture project to monorepo
  - Remove embedded git repository

- Unify all package names to @{project}/{app} schema:
  - @maerchenzauber/* (was @storyteller/*)
  - @manacore/* (was manacore-*, manacore)
  - @manadeck/* (was web, backend, manadeck)
  - @memoro/* (was memoro-web, landing, memoro)
  - @picture/* (already unified)
  - @uload/web

- Add convenient dev scripts for all apps:
  - pnpm dev:{project}:web
  - pnpm dev:{project}:landing
  - pnpm dev:{project}:mobile
  - pnpm dev:{project}:backend

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 04:00:36 +01:00

2.5 KiB

🐛 process-jobs Function - Bug Fix Plan

Problem

Die process-jobs Edge Function wirft einen Runtime Error:

{"success":false,"error":"Cannot read properties of undefined (reading 'substring')"}

Root Cause Analysis

Der Fehler tritt auf, bevor unser Code überhaupt läuft. Mögliche Ursachen:

  1. Import Problem: import { processGeneration } from '../process-generation/index.ts';

    • Dieser relative Import könnte bei Deno/Edge Functions Probleme verursachen
    • Das File wird zwar hochgeladen, aber vielleicht nicht korrekt aufgelöst
  2. Supabase Client: Der createClient() Call schlägt fehl wenn SUPABASE_URL leer ist

    • Der Error reading 'substring' deutet auf URL-Parsing hin

Solution Options

Option A: Inline process-generation Code (EMPFOHLEN)

Pros:

  • Keine Import-Probleme
  • Alle Funktionalität in einer Datei
  • Einfacher zu debuggen

Cons:

  • Code-Duplizierung
  • Größere Datei (~1000 Zeilen)

Option B: Fix Import Path

Pros:

  • Saubere Code-Organisation
  • Wiederverwendbarkeit

Cons:

  • Schwierig zu debuggen
  • Deno Import-Semantik kann tricky sein

Option C: Separate Functions (No Imports)

Pros:

  • Klare Trennung
  • Einfachere Edge Function

Cons:

  • Mehr HTTP Overhead
  • Komplexere Orchestrierung

Da wir processGeneration nur in process-jobs verwenden, macht es Sinn, den Code zu inlinen.

Steps:

  1. Kopiere process-generation Code in process-jobs
  2. Entferne den Import
  3. Deploy und teste

Alternative Quick Fix

Falls das nicht funktioniert, können wir auch:

  1. Nur download-image Jobs verarbeiten
  2. generate-image Jobs über eine HTTP POST an process-generation delegieren

Testing Plan

  1. Minimal Test:

    curl -X POST \
      https://mjuvnnjxwfwlmxjsgkqu.supabase.co/functions/v1/process-jobs \
      -H 'Authorization: Bearer SERVICE_ROLE_KEY'
    

    Should return: {"success": true, "processed": 0, "errors": 0}

  2. With Job Test:

    -- Create test job
    SELECT enqueue_job(
      'generate-image',
      '{"generation_id": "test", "prompt": "test", "model_id": "flux-schnell"}'::jsonb,
      0
    );
    

    Then trigger process-jobs and check if job is claimed.

  3. Full E2E Test: Use start-generation with authenticated user and watch the full flow.

Implementation

Ich würde vorschlagen:

  1. Erstelle eine process-jobs-v2.ts mit inline Code
  2. Deploye als neue Function
  3. Teste
  4. Wenn erfolgreich, ersetze die alte

Will ich das jetzt implementieren?