[GH-ISSUE #701] Unable to set active organization when using secondary storage #17016

Closed
opened 2026-04-15 14:57:38 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @Roronoa-Zoroo on GitHub (Nov 29, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/701

Describe the bug
Unable to set active organization when using Secondary storage (Redis).
Creating organization also throw the same error but organization is created

To Reproduce
Use Redis as secondary storage
I am using ioredis here

secondaryStorage: {
    get: async (key) => {
      const resp = await redis.get(key);
      if (resp) {
        return JSON.parse(resp);
      }
      return resp;
    },
    set: async (key, value, ttl) => {
      if (ttl) await redis.set(key, JSON.stringify(value), "EX", ttl);
      else await redis.set(key, JSON.stringify(value));
    },
    delete: async (key) => {
      await redis.del(key);
    },
  },

try to create organization or setting active organization

await authClient.organization.create({
     name: "Test org1",
     slug: "test-org1",
   });
await authClient.organization.setActive({
     organizationId: "xxx",
   });

image

Originally created by @Roronoa-Zoroo on GitHub (Nov 29, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/701 **Describe the bug** Unable to set active organization when using Secondary storage (Redis). Creating organization also throw the same error but organization is created **To Reproduce** Use Redis as secondary storage I am using ioredis here ``` secondaryStorage: { get: async (key) => { const resp = await redis.get(key); if (resp) { return JSON.parse(resp); } return resp; }, set: async (key, value, ttl) => { if (ttl) await redis.set(key, JSON.stringify(value), "EX", ttl); else await redis.set(key, JSON.stringify(value)); }, delete: async (key) => { await redis.del(key); }, }, ``` try to create organization or setting active organization ``` await authClient.organization.create({ name: "Test org1", slug: "test-org1", }); ``` ``` await authClient.organization.setActive({ organizationId: "xxx", }); ``` ![image](https://github.com/user-attachments/assets/0a2d4f4e-15e2-465b-b6ff-2a98951e243f)
GiteaMirror added the locked label 2026-04-15 14:57:38 -05:00
Author
Owner

@Bekacru commented on GitHub (Nov 29, 2024):

Hey could you confirm if this is still an issue on 1.0.8-beta.1

<!-- gh-comment-id:2508221721 --> @Bekacru commented on GitHub (Nov 29, 2024): Hey could you confirm if this is still an issue on 1.0.8-beta.1
Author
Owner

@Roronoa-Zoroo commented on GitHub (Nov 29, 2024):

just checked
Errors out when setting active organization but not on creating org

<!-- gh-comment-id:2508223301 --> @Roronoa-Zoroo commented on GitHub (Nov 29, 2024): just checked Errors out when setting active organization but not on creating org
Author
Owner

@Bekacru commented on GitHub (Dec 2, 2024):

should be resolved on 1.0.8

<!-- gh-comment-id:2510786953 --> @Bekacru commented on GitHub (Dec 2, 2024): should be resolved on `1.0.8`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17016