{"record":{"id":"a8a18ad2078fb0cd","repo":"HKUDS/DeepTutor","slug":"unknown-user-id-user-id","errorCode":null,"errorMessage":"Unknown user id: {user_id}","messagePattern":"Unknown user id: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/multi_user/grants.py","lineNumber":104,"sourceCode":"    exec_enabled = payload.get(\"exec_enabled\")\n    base[\"exec_enabled\"] = bool(exec_enabled) if isinstance(exec_enabled, bool) else None\n    return base\n\n\ndef load_grant(user_id: str) -> dict[str, Any]:\n    path = grant_path(user_id)\n    if not path.exists():\n        return empty_grant(user_id)\n    try:\n        return normalize_grant(user_id, json.loads(path.read_text(encoding=\"utf-8\")))\n    except Exception:\n        return empty_grant(user_id)\n\n\ndef save_grant(user_id: str, payload: dict[str, Any]) -> dict[str, Any]:\n    user_record = get_user_by_id(user_id)\n    if user_record is None:\n        raise ValueError(f\"Unknown user id: {user_id}\")\n    _username, record = user_record\n    if str(record.get(\"role\") or \"user\") == \"admin\":\n        raise ValueError(\"Admin users use the main workspace and cannot receive assignments.\")\n    grant = normalize_grant(user_id, payload)\n    validate_grant(grant)\n    path = grant_path(user_id)\n    path.parent.mkdir(parents=True, exist_ok=True)\n    path.write_text(json.dumps(grant, indent=2, ensure_ascii=False), encoding=\"utf-8\")\n    return grant\n\n\ndef validate_grant(grant: dict[str, Any]) -> None:\n    \"\"\"Reject accidental secret/path material in grants.\n\n    Grants carry logical ids only. Runtime resolution happens server-side.\n    \"\"\"\n    forbidden = {\"api_key\", \"secret\", \"password\", \"token\", \"path\", \"base_url\"}\n","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/multi_user/grants.py#L86-L122","documentation":"Error \"Unknown user id: {user_id}\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/multi_user/grants.py:104 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}