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
apps/sim/lib/credentials/environment.ts — ensureWorkspaceCredentialMemberships: only checks ownerUserId, ignores workspace permissions table
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
- Create a workspace with multiple members (owner + admin + write/read users)
- As the owner, go to Settings > Secrets and create a workspace-scoped secret
- Check
credential_member table — only the owner has admin role
- Log in as a workspace admin user — cannot edit or delete the secret
Bug Description
When a workspace-scoped secret is created (via Settings > Secrets or
syncWorkspaceEnvCredentials), thecredential_memberrole is determined solely by whether the user is the workspace owner:This means workspace admin users are assigned
memberrole oncredential_member, making them unable to edit or delete the secret — even though they have admin access to the workspace.Affected Code
apps/sim/lib/credentials/environment.ts—ensureWorkspaceCredentialMemberships: only checksownerUserId, ignores workspacepermissionstableapps/sim/app/api/credentials/route.ts— POST handler: same issue, onlyworkspaceRow.ownerId || session.user.idgets adminExpected Behavior
Credential member role should reflect workspace permissions:
workspace.ownerId)Steps to Reproduce
credential_membertable — only the owner hasadminrole