{"record":{"id":"bb3882d84bfedbd5","repo":"invoke-ai/InvokeAI","slug":"admin-privileges-required","errorCode":null,"errorMessage":"Admin privileges required","messagePattern":"Admin privileges required","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"invokeai/app/api/auth_dependencies.py","lineNumber":237,"sourceCode":") -> TokenData:\n    \"\"\"Require admin role for the current user.\n\n    Stays `async def`, unlike the dependencies it builds on: this only reads a field off the\n    already-resolved token data. Declaring it `def` would buy a threadpool round-trip per admin\n    request and nothing else. The `users.get` that can block lives in `get_current_user`, which\n    is synchronous for that reason.\n\n    Args:\n        current_user: The current authenticated user's token data\n\n    Returns:\n        The token data if user is an admin\n\n    Raises:\n        HTTPException: If user does not have admin privileges (403 Forbidden)\n    \"\"\"\n    if not current_user.is_admin:\n        raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=\"Admin privileges required\")\n    return current_user\n\n\ndef require_admin_or_default(\n    current_user: Annotated[TokenData, Depends(get_current_user_or_default)],\n) -> TokenData:\n    \"\"\"Require admin role for the current user, or return default system admin in single-user mode.\n\n    `async def` for the same reason as `require_admin`: it does no blocking work of its own.\n\n    This dependency is useful for admin-only endpoints that should work in both single-user and multiuser modes.\n\n    When multiuser mode is disabled (default), this always returns a system user with admin privileges.\n    When multiuser mode is enabled, this validates that the authenticated user has admin privileges.\n\n    Args:\n        current_user: The current authenticated user's token data (or default system user)\n","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/auth_dependencies.py#L219-L255","documentation":"SpandrelModelLoader.load_from_file wraps spandrel's ModelLoader and only supports ImageModelDescriptor (image-to-image models). If spandrel loads the file into a different descriptor type the ValueError is raised naming the loaded type.","triggerScenarios":"Loading a spandrel model file that is a VideoModelDescriptor (video SR), an unsupported architecture that spandrel wraps differently, or a corrupted/non-standard ESRGAN/ONNX file that yields a non-image descriptor.","commonSituations":"Dropping a video-upscaler or unsupported architecture .pth into InvokeAI's models directory, installing a spandrel version that changed descriptor classes, or selecting the wrong model file in the UI for the upscaling node.","solutions":["Use an image-to-image model (ESRGAN, Real-ESRGAN, SwinIR, GFPGAN, etc.) that spandrel exposes as ImageModelDescriptor","Check the model file: replace video/unsupported models with a supported image upscaler","Upgrade or pin the spandrel dependency so the architecture is recognized as an image model","Verify the .pth isn't corrupted or a checkpoint of the wrong kind by loading it with spandrel's ModelLoader directly"],"exampleFix":"// before\nmodel = SpandrelImageToImageModel.load_from_file(\"video_sr_model.pth\")  # VideoModelDescriptor\n// after\nmodel = SpandrelImageToImageModel.load_from_file(\"4x_NMKD-Superscale.pth\")  # ImageModelDescriptor","handlingStrategy":"type-guard","validationCode":"from spandrel import ImageModelDescriptor\nfrom spandrel_extra_arches import ExtraModelLoader  # optional arches\nm = ModelLoader().load_from_file(path)\nassert isinstance(m, ImageModelDescriptor), type(m)","typeGuard":"from spandrel import ImageModelDescriptor\ndef is_image_to_image_model(model) -> bool:\n    return isinstance(model, ImageModelDescriptor)","tryCatchPattern":"try:\n    model = SpandrelImageToImageModel.load_from_file(path)\nexcept ValueError as e:\n    if \"ImageModelDescriptor\" in str(e):\n        raise RuntimeError(f\"{path} is not an image-to-image model; pick a supported upscaler\") from e\n    raise","preventionTips":["Only install models known to be image-to-image (ESRGAN/SwinIR/etc.)","Pre-check with spandrel's ModelLoader and isinstance before use","Keep spandrel (and extra arches) updated for architecture support","Separate video/unsupported model files from InvokeAI's model dir"],"tags":["model-loading","spandrel","type-validation","upscaling"],"backgroundTag":"unsupported-model-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}