Comfy-Org/ComfyUI · error · ValueError

System User prefix not allowed

Error message

System User prefix not allowed

What it means

add_user refuses display names that start with folder_paths.SYSTEM_USER_PREFIX ('__') because that prefix marks ComfyUI's own reserved directories/files. The check runs on the raw (stripped) name before any id sanitization, so a name like '__admin' is rejected immediately.

Source

Thrown at app/user_manager.py:110

            # prevent leaving /{type}/{user}
            path = os.path.abspath(os.path.join(user_root, file))
            if os.path.commonpath((user_root, path)) != user_root:
                return None

        parent = os.path.split(path)[0]

        if create_dir and not os.path.exists(parent):
            os.makedirs(parent, exist_ok=True)

        return path

    def add_user(self, name):
        name = name.strip()
        if not name:
            raise ValueError("username not provided")
        if name.startswith(folder_paths.SYSTEM_USER_PREFIX):
            raise ValueError("System User prefix not allowed")
        user_id = re.sub("[^a-zA-Z0-9-_]+", '-', name)
        if user_id.startswith(folder_paths.SYSTEM_USER_PREFIX):
            raise ValueError("System User prefix not allowed")
        user_id = user_id + "_" + str(uuid.uuid4())

        self.users[user_id] = name

        with open(self.get_users_file(), "w") as f:
            json.dump(self.users, f)

        return user_id

    def add_routes(self, routes):
        self.settings.add_routes(routes)

        @routes.get("/users")
        async def get_users(request):
            if args.multi_user:

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Pick a name that does not start with '__', e.g. "internal" instead of "__internal".
  2. Enforce the rule client-side: reject names where name.strip().startswith('__').

Example fix

# before
user_manager.add_user("__admin")

# after
user_manager.add_user("admin")
Defensive patterns

Strategy: validation

Validate before calling

import folder_paths
name = name.strip()
if name.startswith(folder_paths.SYSTEM_USER_PREFIX):
    raise ValueError("reserved prefix")
user_manager.add_user(name)

Type guard

import folder_paths
def name_has_reserved_prefix(name: str) -> bool:
    return name.strip().startswith(folder_paths.SYSTEM_USER_PREFIX)

Try / catch

try:
    user_manager.add_user(name)
except ValueError as e:
    return web.Response(status=400, text=str(e))

Prevention

When it happens

Trigger: Calling add_user with a name beginning with two underscores, e.g. "__internal"; user-creation automation that prefixes names with '__'.

Common situations: Naming conventions that use leading underscores for special accounts; attempts to impersonate/overlap system storage paths; copy-pasting a system directory name as a username.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/70664bc55ef8f068. Report an issue: GitHub.