fix: Remove broken table_exists check
All checks were successful
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s

Removed faulty EXISTS check that was causing "0" error.
Added debug logging and better error messages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-03-27 07:34:29 +01:00
parent 484c25575d
commit 8be87bfdfb
2 changed files with 10 additions and 22 deletions

View File

@ -504,26 +504,10 @@ def list_goal_type_definitions(session: dict = Depends(require_auth)):
with get_db() as conn:
cur = get_cursor(conn)
# Check if table exists first
cur.execute("""
SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_name = 'goal_type_definitions'
)
""")
table_exists = cur.fetchone()[0]
if not table_exists:
print("[ERROR] goal_type_definitions table does not exist!")
raise HTTPException(
status_code=500,
detail="Goal Types Tabelle existiert nicht. Migration 024 muss ausgeführt werden."
)
cur.execute("""
SELECT id, type_key, label_de, label_en, unit, icon, category,
source_table, source_column, aggregation_method,
calculation_formula, description, is_system,
calculation_formula, description, is_system, is_active,
created_at, updated_at
FROM goal_type_definitions
WHERE is_active = true
@ -535,9 +519,10 @@ def list_goal_type_definitions(session: dict = Depends(require_auth)):
label_de
""")
return [r2d(row) for row in cur.fetchall()]
except HTTPException:
raise
results = [r2d(row) for row in cur.fetchall()]
print(f"[DEBUG] Loaded {len(results)} goal types")
return results
except Exception as e:
print(f"[ERROR] list_goal_type_definitions failed: {e}")
print(traceback.format_exc())

View File

@ -40,11 +40,14 @@ export default function AdminGoalTypesPage() {
const loadGoalTypes = async () => {
setLoading(true)
setError(null)
try {
const data = await api.listGoalTypeDefinitions()
setGoalTypes(data)
console.log('[DEBUG] Loaded goal types:', data)
setGoalTypes(data || [])
} catch (err) {
setError('Fehler beim Laden der Goal Types')
console.error('[ERROR] Failed to load goal types:', err)
setError(`Fehler beim Laden der Goal Types: ${err.message || err.toString()}`)
} finally {
setLoading(false)
}