HKUDS/DeepTutor · error · ValueError
Admin users use the main workspace and cannot receive…
Error message
Admin users use the main workspace and cannot receive assignments.
What it means
save_grant explicitly refuses assignments for admin users: admins work out of the main workspace and already have full access, so per-user grant assignments are meaningless and are rejected to keep the grant model coherent.
Solutions
- Remove the admin-role check by targeting a non-admin learner account
- Manage admin content directly in the main workspace instead of grants
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/multi_user/grants.py:107 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/0d8dc039e3ede35c.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/multi_user/grants.py:107
def load_grant(user_id: str) -> dict[str, Any]:
path = grant_path(user_id)
if not path.exists():
return empty_grant(user_id)
try:
return normalize_grant(user_id, json.loads(path.read_text(encoding="utf-8")))
except Exception:
return empty_grant(user_id)
def save_grant(user_id: str, payload: dict[str, Any]) -> dict[str, Any]:
user_record = get_user_by_id(user_id)
if user_record is None:
raise ValueError(f"Unknown user id: {user_id}")
_username, record = user_record
if str(record.get("role") or "user") == "admin":
raise ValueError("Admin users use the main workspace and cannot receive assignments.")
grant = normalize_grant(user_id, payload)
validate_grant(grant)
path = grant_path(user_id)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(grant, indent=2, ensure_ascii=False), encoding="utf-8")
return grant
def validate_grant(grant: dict[str, Any]) -> None:
"""Reject accidental secret/path material in grants.
Grants carry logical ids only. Runtime resolution happens server-side.
"""
forbidden = {"api_key", "secret", "password", "token", "path", "base_url"}
def walk(value: Any, trail: str = "grant") -> None:
if isinstance(value, dict):
for key, child in value.items():View on GitHub (pinned to 3e82f13042)