Read the API key list before the next query replaces it.
Deploy Development / deploy (push) Successful in 54s
Test Suite / pytest-backend (push) Failing after 29s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 23s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m41s

The exercise release screen asked which keys match and then looked up club roles on the same cursor. The key rows were discarded, so a valid key looked missing.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-23 14:34:15 +01:00
1 parent b824115e9b
commit 4b33b17b2d
3 files changed
+56 -5

No files matched your search

+2 -2
View File
@@ -1538,6 +1538,8 @@ def release_keys_for_exercise(cur, exercise: dict, profile_id: int, role: str) -
return [], denial
if vis == "club" and exercise.get("club_id") is not None and not _api_enabled(cur, int(exercise["club_id"])):
return [], "Die API-Schnittstelle ist für diesen Verein nicht freigegeben."
admin_ids = _club_ids_with_role(cur, profile_id, "club_admin")
member_ids = _club_ids_with_role(cur, profile_id, None)
cur.execute(
"""
SELECT k.id, k.label, k.context_kind, k.context_club_id, k.context_profile_id, k.club_ids,
@@ -1552,8 +1554,6 @@ def release_keys_for_exercise(cur, exercise: dict, profile_id: int, role: str) -
""",
(vis,),
)
admin_ids = _club_ids_with_role(cur, profile_id, "club_admin")
member_ids = _club_ids_with_role(cur, profile_id, None)
keys = []
for row in _rows(cur):
item = r2d(row)
+45 -1
View File
@@ -14,7 +14,7 @@ from fastapi.testclient import TestClient
os.environ.setdefault("SKIP_DB_MIGRATE", "1")
from auth import require_auth
from distribution_service import _lock_recipient
from distribution_service import _lock_recipient, release_keys_for_exercise
from distribution_contract import (
InvalidCursor,
actions_cover,
@@ -237,6 +237,50 @@ def test_distribution_read_is_hidden_while_disabled(client: TestClient, monkeypa
assert response.headers.get("cache-control") == "private, no-store"
class _DroppingCursor:
"""Ein neues execute verwirft ein noch nicht gelesenes Ergebnis, wie psycopg2."""
def __init__(self, key: dict) -> None:
self._key = key
self._pending = None
def execute(self, sql, _params=None):
if self._pending is not None:
raise AssertionError("Ergebnis wurde vor dem Lesen überschrieben")
self._pending = [self._key] if "FROM distribution_keys" in sql else []
def fetchall(self):
rows = self._pending
self._pending = None
return rows or []
def fetchone(self):
rows = self.fetchall()
return rows[0] if rows else None
def test_release_screen_keeps_the_application_key() -> None:
key = {
"id": "key-1",
"label": "Lara",
"context_kind": "user",
"context_club_id": None,
"context_profile_id": 7,
"club_ids": [3],
"recipient_id": "rec-1",
"api_enabled": True,
}
cur = _DroppingCursor(key)
keys, block = release_keys_for_exercise(
cur,
{"visibility": "official", "club_id": None, "created_by": 7},
7,
"superadmin",
)
assert block is None
assert [item["label"] for item in keys] == ["Lara"]
def test_channel_sequence_is_locked() -> None:
assert "FOR UPDATE" in inspect.getsource(_lock_recipient)
+9 -2
View File
@@ -1,6 +1,6 @@
# Shinkan Jinkendo Version Information
APP_VERSION = "0.8.254"
APP_VERSION = "0.8.255"
BUILD_DATE = "2026-11-23"
DB_SCHEMA_VERSION = "20261123101"
@@ -39,7 +39,7 @@ MODULE_VERSIONS = {
"skill_profiles": "1.0.0", # Phase 3: gewichtetes Fähigkeiten-Profil + skill-discovery/suggestions
"methods": "0.1.0",
"exercises": "2.38.0", # Globale Übungen schreibt und gibt nur superadmin frei
"distribution": "1.3.0", # Ein Schlüssel je Anwendung, Rechte folgen der aktuellen Rolle, Schlüssel bleibt kopierbar
"distribution": "1.3.1", # Freigabe liest den Schlüssel, bevor weitere Abfragen denselben Cursor benutzen
"planning_exercise_suggest": "0.23.8", # Progressionsgraph: Katalog-Kontext (Fokus/Stil/TT/ZG) im Match-Profil
"training_units": "0.4.0", # POST .../publish-to-framework: Ablauf aus geplanter Einheit → Rahmen-Slot-Blueprint
"training_programs": "0.1.0",
@@ -55,6 +55,13 @@ MODULE_VERSIONS = {
}
CHANGELOG = [
{
"version": "0.8.255",
"date": "2026-11-23",
"changes": [
"Die Übungsfreigabe findet einen angelegten API-Schlüssel. Die Schlüsselabfrage wird gelesen, bevor die Rollenabfrage denselben Cursor überschreibt.",
],
},
{
"version": "0.8.254",
"date": "2026-11-23",