Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export function Integrations({ onOpenChange, registerCloseHandler }: Integration
(acc, service) => {
if (
permissionConfig.allowedIntegrations !== null &&
!permissionConfig.allowedIntegrations.includes(service.id.replace(/-/g, '_'))
!permissionConfig.allowedIntegrations.includes(service.id.replace(/-/g, '_').toLowerCase())
) {
return acc
}
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/hooks/use-permission-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function useAllowedIntegrationsFromEnv() {
*/
function intersectAllowlists(a: string[] | null, b: string[] | null): string[] | null {
if (a === null) return b
if (b === null) return a
if (b === null) return a.map((i) => i.toLowerCase())
return a.map((i) => i.toLowerCase()).filter((i) => b.includes(i))
Comment on lines 46 to 48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent lowercasing across branches

When a === null, b is returned as-is (line 46), but when b === null, a is now lowercased (line 47). On line 48, a is lowercased but b is not lowercased before filtering. While this currently works because b (the env allowlist) is already lowercase from getAllowedIntegrationsFromEnv(), the asymmetry makes the function fragile — if b ever comes from a source that isn't pre-lowercased, the intersection on line 48 would silently drop valid entries.

Consider normalizing both inputs uniformly:

Suggested change
if (a === null) return b
if (b === null) return a
if (b === null) return a.map((i) => i.toLowerCase())
return a.map((i) => i.toLowerCase()).filter((i) => b.includes(i))
if (a === null) return b?.map((i) => i.toLowerCase()) ?? null
if (b === null) return a.map((i) => i.toLowerCase())
return a.map((i) => i.toLowerCase()).filter((i) => b.map((j) => j.toLowerCase()).includes(i))

}

Expand Down