feat: FIX RedisLock REDIS_KEY_PREFIX #6235

Closed
opened 2025-11-11 16:48:48 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @AlbertDoesProgramming on GitHub (Aug 27, 2025).

Check Existing Issues

  • I have searched the existing issues and discussions.

Problem Description

Previously a feature was added to allow a prefix to be added to keys in redis using the environmental variable: REDIS_KEY_PREFIX

I'm wondering why in open_webui/socket/main.py, the RedisLock doesn't also use the REDIS_KEY_PREFIX.

I'm using ACLs to manage my redis security framework, and I want to gate OWUI access to redis behind access to keys with a certain shape, for example: ~open-webui-1:*. But the prefix isn't added to the name of the the RedisLock, and so when the lock fires, it throws because the key this creates would be out of scope.

Here's the code in question:

    clean_up_lock = RedisLock(
        redis_url=WEBSOCKET_REDIS_URL,
        lock_name="usage_cleanup_lock",
        timeout_secs=WEBSOCKET_REDIS_LOCK_TIMEOUT,
        redis_sentinels=redis_sentinels,
        redis_cluster=WEBSOCKET_REDIS_CLUSTER,
    )

Desired Solution you'd like

I would like for the prefix to also be added to the name of the lock:

    clean_up_lock = RedisLock(
        redis_url=WEBSOCKET_REDIS_URL,
        lock_name=f"{REDIS_KEY_PREFIX}:usage_cleanup_lock",
        timeout_secs=WEBSOCKET_REDIS_LOCK_TIMEOUT,
        redis_sentinels=redis_sentinels,
        redis_cluster=WEBSOCKET_REDIS_CLUSTER,
    )

Alternatives Considered

So there may be good reason for why this has been left the way it is, and I would love to be educated if that's the case! The alternative for my use case, is adding key for the RedisLock to my ACL for the relevant user. But in a shared redis instance with multiple tenants, something about this feels wrong to me.

Additional Context

There's some relevant related issues here:

What spurred me to create this issue was the discussion I contributed to on 16157.

Originally created by @AlbertDoesProgramming on GitHub (Aug 27, 2025). ### Check Existing Issues - [x] I have searched the existing issues and discussions. ### Problem Description Previously a feature was added to allow a prefix to be added to keys in redis using the environmental variable: REDIS_KEY_PREFIX I'm wondering why in [open_webui/socket/main.py](https://github.com/open-webui/open-webui/blob/1db8dec4f52fc0fa8f8f7bfbb8ea5bde41fee17d/backend/open_webui/socket/main.py#L118), the RedisLock doesn't also use the REDIS_KEY_PREFIX. I'm using ACLs to manage my redis security framework, and I want to gate OWUI access to redis behind access to keys with a certain shape, for example: ~open-webui-1:*. But the prefix isn't added to the name of the the RedisLock, and so when the lock fires, it throws because the key this creates would be out of scope. Here's the code in question: ```python clean_up_lock = RedisLock( redis_url=WEBSOCKET_REDIS_URL, lock_name="usage_cleanup_lock", timeout_secs=WEBSOCKET_REDIS_LOCK_TIMEOUT, redis_sentinels=redis_sentinels, redis_cluster=WEBSOCKET_REDIS_CLUSTER, ) ``` ### Desired Solution you'd like I would like for the prefix to also be added to the name of the lock: ```python clean_up_lock = RedisLock( redis_url=WEBSOCKET_REDIS_URL, lock_name=f"{REDIS_KEY_PREFIX}:usage_cleanup_lock", timeout_secs=WEBSOCKET_REDIS_LOCK_TIMEOUT, redis_sentinels=redis_sentinels, redis_cluster=WEBSOCKET_REDIS_CLUSTER, ) ``` ### Alternatives Considered So there may be good reason for why this has been left the way it is, and I would love to be educated if that's the case! The alternative for my use case, is adding key for the RedisLock to my ACL for the relevant user. But in a shared redis instance with multiple tenants, something about this _feels_ wrong to me. ### Additional Context There's some relevant related issues here: - [issue 16157](https://github.com/open-webui/open-webui/issues/16157#issuecomment-3229620309) - [issue 15074](https://github.com/open-webui/open-webui/issues/15074) What spurred me to create this issue was the discussion I contributed to on 16157.
Author
Owner

@tjbck commented on GitHub (Aug 27, 2025):

Addressed in dev!

@tjbck commented on GitHub (Aug 27, 2025): Addressed in dev!
Author
Owner

@AlbertDoesProgramming commented on GitHub (Aug 28, 2025):

Thanks everyone, title changed. Appreciate you guys addressing so quickly!

@AlbertDoesProgramming commented on GitHub (Aug 28, 2025): Thanks everyone, title changed. Appreciate you guys addressing so quickly!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#6235