{"record":{"id":"ff25d5633820467e","repo":"invoke-ai/InvokeAI","slug":"queue-user-is-not-authorized-to-save-images","errorCode":null,"errorMessage":"Queue user is not authorized to save images","messagePattern":"Queue user is not authorized to save images","errorType":"exception","errorClass":"PermissionError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/shared/invocation_context.py","lineNumber":239,"sourceCode":"        metadata_ = None\n        if metadata:\n            metadata_ = metadata.model_dump_json()\n        elif isinstance(self._data.invocation, WithMetadata) and self._data.invocation.metadata:\n            metadata_ = self._data.invocation.metadata.model_dump_json()\n\n        # If `board_id` is provided directly, use that. Else, use the board provided by `WithBoard`, falling back to None.\n        board_id_ = None\n        if board_id:\n            board_id_ = board_id\n        elif isinstance(self._data.invocation, WithBoard) and self._data.invocation.board:\n            board_id_ = self._data.invocation.board.board_id\n\n        if self._services.configuration.multiuser:\n            user = self._services.users.get(self._data.queue_item.user_id)\n            # A deactivated or deleted account must not save outputs, even\n            # uncategorized ones — deactivation revokes queue-time privileges.\n            if user is None or not user.is_active:\n                raise PermissionError(\"Queue user is not authorized to save images\")\n            if board_id_ is not None:\n                board = self._services.boards.get_dto(board_id_)\n                if (\n                    not user.is_admin\n                    and board.user_id != self._data.queue_item.user_id\n                    and board.board_visibility != BoardVisibility.Public\n                ):\n                    raise PermissionError(\"Queue user is not authorized to save images to this board\")\n\n        workflow_ = None\n        if self._data.queue_item.workflow:\n            workflow_ = self._data.queue_item.workflow.model_dump_json()\n\n        graph_ = None\n        if self._data.queue_item.session.graph:\n            graph_ = self._data.queue_item.session.graph.model_dump_json()\n\n        return self._services.images.create(","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/shared/invocation_context.py#L221-L257","documentation":"ImagesInterface.save throws PermissionError in multiuser mode when the queue item's user account is missing or deactivated. Deactivation revokes all queue-time privileges, including saving outputs of already-running graphs.","triggerScenarios":"An invocation calls images.save (optionally with board_id) while self._services.configuration.multiuser is true and users.get(queue_item.user_id) returns None or a user with is_active=False.","commonSituations":"Admin bans/deletes a user mid-run; their in-flight queue items hit the save step and fail; long-running batches spanning account deactivation.","solutions":["Reactivate the user account before the queue item reaches its save step","Cancel/purge that user's pending queue items before deactivating the account","Run the generation under an active account","Catch PermissionError around images.save and skip persisting the output"],"exampleFix":"# before\nclass DeactivatedUserWorkflow:\n    def invoke(self, context):\n        context.images.save(image)  # raises PermissionError\n# after: ensure user active or catch\ndef invoke(self, context):\n    try:\n        context.images.save(image)\n    except PermissionError:\n        logger.warning(\"user deactivated; output not saved\")","handlingStrategy":"try-catch","validationCode":"cfg = services.configuration\nuser = services.users.get(queue_item.user_id) if cfg.multiuser else True\nif cfg.multiuser and (user is None or not user.is_active):\n    raise SkipSave(\"queue user deactivated\")","typeGuard":"def can_save(services, queue_item) -> bool:\n    if not services.configuration.multiuser:\n        return True\n    user = services.users.get(queue_item.user_id)\n    return user is not None and user.is_active","tryCatchPattern":"try:\n    context.images.save(image, board_id=board_id)\nexcept PermissionError:\n    logger.warning(\"save rejected: queue user lacks privileges\")","preventionTips":["Purge a user's queue before deactivating them","Avoid long batches tied to accounts slated for removal","Handle PermissionError around all save calls in custom nodes","Verify multiuser mode when testing node save logic"],"tags":["permissions","multiuser","invokeai","image-save"],"backgroundTag":"permission-denied","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}