{"record":{"id":"fc0a509683fba0aa","repo":"HKUDS/DeepTutor","slug":"this-model-is-not-assigned-to-your-account","errorCode":null,"errorMessage":"This model is not assigned to your account.","messagePattern":"This model is not assigned to your account\\.","errorType":"exception","errorClass":"PermissionError","httpStatus":null,"severity":"error","filePath":"deeptutor/multi_user/model_access.py","lineNumber":167,"sourceCode":"    if user.is_admin:\n        return True\n    if user_id is None:\n        user_id = user.id\n    items = redacted_model_access(user_id).get(capability, []) or []\n    return any(item.get(\"available\") for item in items)\n\n\ndef apply_allowed_llm_selection(selection: dict[str, Any] | None) -> dict[str, Any] | None:\n    \"\"\"Allow only admin-granted LLM profile/model selections for ordinary users.\"\"\"\n    user = get_current_user()\n    if user.is_admin or not selection:\n        return selection\n    profile_id = str(selection.get(\"profile_id\") or \"\")\n    model_id = str(selection.get(\"model_id\") or \"\")\n    for item in redacted_model_access(user.id).get(\"llm\", []):\n        if item.get(\"profile_id\") == profile_id and item.get(\"model_id\") == model_id:\n            return selection\n    raise PermissionError(\"This model is not assigned to your account.\")\n","sourceCodeStart":149,"sourceCodeEnd":168,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/multi_user/model_access.py#L149-L168","documentation":"PermissionError from apply_allowed_llm_selection: the submitted LLM selection's (profile_id, model_id) pair does not appear in redacted_model_access(user.id)['llm'], i.e. the model was never granted (or was redacted away) for the current user.","triggerScenarios":"Submitting an LLM selection payload with a profile_id/model_id combination not granted; using a codex profile bound to a different owner; saving grants after an admin revoked the model; stale client-side model picker state.","commonSituations":"Multi-user grants where admins restrict models; owner-bound codex profiles leaking into pickers; switching accounts with cached selections.","solutions":["Refresh the model list from the user's accessible models endpoint and re-select from it","Ask an admin to grant the model/profile to the user","Clear the stale saved selection before starting a turn"],"exampleFix":"// before\napply_allowed_llm_selection({\"profile_id\": \"codex-owner\", \"model_id\": \"gpt-x\"})\n# PermissionError\n\n// after\nallowed = redacted_model_access(user.id)[\"llm\"]\nsel = next(m for m in allowed if m[\"model_id\"] == \"gpt-x\")\napply_allowed_llm_selection({\"profile_id\": sel[\"profile_id\"], \"model_id\": sel[\"model_id\"]})","handlingStrategy":"validation","validationCode":"allowed = {(m[\"profile_id\"], m[\"model_id\"]) for m in redacted_model_access(user.id)[\"llm\"]}\nif (sel[\"profile_id\"], sel[\"model_id\"]) not in allowed:\n    sel = next(iter(allowed))  # reset to a granted model","typeGuard":"def selection_allowed(selection: dict, user) -> bool:\n    allowed = redacted_model_access(user.id)[\"llm\"]\n    return any(m[\"profile_id\"] == selection.get(\"profile_id\") and m[\"model_id\"] == selection.get(\"model_id\") for m in allowed)","tryCatchPattern":"try:\n    apply_allowed_llm_selection(selection)\nexcept PermissionError:\n    selection = default_granted_selection(user)  # re-pick from allowed list\n    apply_allowed_llm_selection(selection)","preventionTips":["Populate model pickers exclusively from the user's redacted model access","Drop owner-bound profiles from shared/user pickers","Reset persisted selections after grants change"],"tags":["llm","permissions","model-access","multi-user"],"backgroundTag":"insufficient-permissions","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}