fix: correct dict cursor access in MediaWiki import
Some checks failed
Deploy Development / deploy (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 5s
Test Suite / playwright-tests (push) Failing after 2m2s

Error: 500 Internal Server Error on execute import
Root cause: Using fetchone()[0] with RealDictCursor (dict-like rows)

PostgreSQL RealDictCursor returns dict-like objects, not tuples.
Accessing [0] on a dict throws TypeError.

Fix: Changed all fetchone()[0] to fetchone()['id']
Locations:
- Line 163: log_id after INSERT INTO wiki_import_log
- Line 485: ex_id after INSERT INTO exercises
- Line 599: skill_id after INSERT INTO skills
- Line 616: method_id after INSERT INTO training_methods

This matches the pattern used in other routers (exercises.py, etc.)
This commit is contained in:
Lars 2026-04-24 20:37:31 +02:00
parent 8b51864b53
commit a37400bb22

View File

@ -160,7 +160,7 @@ async def execute_import(
RETURNING id""",
(body.import_type, body.category, body.dry_run, body.reimport_existing, profile_id)
)
log_id = cur.fetchone()[0]
log_id = cur.fetchone()['id']
conn.commit()
# Import asynchron starten
@ -482,7 +482,7 @@ def _upsert_exercise(mapped: dict, reimport: bool) -> Optional[int]:
mapped.get("import_id"),
)
)
ex_id = cur.fetchone()[0]
ex_id = cur.fetchone()['id']
conn.commit()
@ -596,7 +596,7 @@ def _upsert_skill(mapped: dict, reimport: bool) -> Optional[int]:
RETURNING id""",
(mapped["name"], mapped.get("description"), category_id)
)
skill_id = cur.fetchone()[0]
skill_id = cur.fetchone()['id']
conn.commit()
return skill_id
@ -613,7 +613,7 @@ def _upsert_method(mapped: dict, reimport: bool) -> Optional[int]:
RETURNING id""",
(mapped["name"], mapped.get("description"))
)
method_id = cur.fetchone()[0]
method_id = cur.fetchone()['id']
conn.commit()
return method_id