fix(credentials): workspace admin users get 'member' role on credential_member instead of 'admin'

Open
#4,698 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #5431 by @tsushanth — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript

Research direction

Start with ensureWorkspaceCredentialMemberships in apps/sim/lib/credentials/environment.ts and the POST handler in apps/sim/app/api/credentials/route.ts; trace how workspace permissions are read and how credential_member roles are assigned. Reproduce the owner, admin, write, and read cases, then verify that owner and admin users receive admin while write and read users receive member.

Written by the indexing model from the issue text.

Description

Bug Description

When a workspace-scoped secret is created (via Settings > Secrets or syncWorkspaceEnvCredentials), the credential_member role is determined solely by whether the user is the workspace owner:

const targetRole = memberUserId === ownerUserId ? 'admin' : 'member'

This means workspace admin users are assigned member role on credential_member, making them unable to edit or delete the secret — even though they have admin access to the workspace.

Affected Code

  1. apps/sim/lib/credentials/environment.ts — ensureWorkspaceCredentialMemberships: only checks ownerUserId, ignores workspace permissions table
  2. apps/sim/app/api/credentials/route.ts — POST handler: same issue, only workspaceRow.ownerId || session.user.id gets admin

Expected Behavior

Credential member role should reflect workspace permissions:

Workspace Permission Credential Role
owner (workspace.ownerId) admin
admin (permissions table) admin
write member
read member

Steps to Reproduce

  1. Create a workspace with multiple members (owner + admin + write/read users)
  2. As the owner, go to Settings > Secrets and create a workspace-scoped secret
  3. Check credential_member table — only the owner has admin role
  4. Log in as a workspace admin user — cannot edit or delete the secret
Dominant language
TypeScript
Stars
29.8k
Forks
3.9k
Avg merge
1h 43m
Merged PRs (30d)
937

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from simstudioai/sim

All issues in simstudioai/sim

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.