Skip to content

fix(repos): Filter null integrations in useScmIntegrationTreeData#110868

Merged
ryan953 merged 2 commits intomasterfrom
ryan953/fix/filter-null-integrations-frontend
Mar 17, 2026
Merged

fix(repos): Filter null integrations in useScmIntegrationTreeData#110868
ryan953 merged 2 commits intomasterfrom
ryan953/fix/filter-null-integrations-frontend

Conversation

@ryan953
Copy link
Copy Markdown
Member

@ryan953 ryan953 commented Mar 17, 2026

The /integrations/ API can return null items in the response list when the backend serializer fails for an individual integration (the backend fix for that is in #110865). The filter call in useScmIntegrationTreeData was accessing i.provider.key without guarding against null items, causing a TypeError that crashed the /settings/repos/ page behind an error boundary.

Add a i !== null guard before accessing .provider.key.

Related to #110865

Fixes JAVASCRIPT-381Y

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 17, 2026
@ryan953 ryan953 force-pushed the ryan953/fix/filter-null-integrations-frontend branch from bd904c8 to 8904e88 Compare March 17, 2026 16:28
@ryan953 ryan953 marked this pull request as ready for review March 17, 2026 16:28
@ryan953 ryan953 requested a review from a team March 17, 2026 16:28
() => (integrationsQuery.data ?? []).filter(i => scmProviderKeys.has(i.provider.key)),
() =>
integrationsQuery.data?.filter(
i => i !== null && scmProviderKeys.has(i.provider.key)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

guard against the null case. the types don't support it though.

related to #110865

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Removing ?? [] makes scmIntegrations crash on .map()
    • Restored the ?? [] fallback to ensure scmIntegrations is always an array, preventing TypeError when .map() is called during query loading.
  • ✅ Fixed: Removing ?? [] makes scmProviders potentially undefined
    • Restored the ?? [] fallback to ensure scmProviders is always an array, preventing TypeError when accessing .length or .map() during query loading.

Create PR

Or push these changes by commenting:

@cursor push 5d1b5bde67
Preview (5d1b5bde67)
diff --git a/static/app/components/repositories/scmIntegrationTree/useScmIntegrationTreeData.ts b/static/app/components/repositories/scmIntegrationTree/useScmIntegrationTreeData.ts
--- a/static/app/components/repositories/scmIntegrationTree/useScmIntegrationTreeData.ts
+++ b/static/app/components/repositories/scmIntegrationTree/useScmIntegrationTreeData.ts
@@ -40,8 +40,8 @@
 
   const scmProviders = useMemo(
     () =>
-      providersQuery.data?.providers
-        ?.filter(p => p.metadata.features.some(f => f.featureGate.includes('commits')))
+      (providersQuery.data?.providers ?? [])
+        .filter(p => p.metadata.features.some(f => f.featureGate.includes('commits')))
         .sort((a, b) => a.name.localeCompare(b.name)),
     [providersQuery.data]
   );
@@ -61,7 +61,7 @@
 
   const scmIntegrations = useMemo(
     () =>
-      integrationsQuery.data?.filter(
+      (integrationsQuery.data ?? []).filter(
         i => i !== null && scmProviderKeys.has(i.provider.key)
       ),
     [integrationsQuery.data, scmProviderKeys]

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@ryan953 ryan953 force-pushed the ryan953/fix/filter-null-integrations-frontend branch from 8904e88 to d8f0e77 Compare March 17, 2026 16:49
The /integrations/ API can return null items in the list when
the backend serializer fails for an integration. Accessing
.provider.key on null causes a TypeError that crashes the
settings/repos/ page with an error boundary.

Guard the filter to skip null items.

Fixes JAVASCRIPT-381Y
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ryan953 ryan953 force-pushed the ryan953/fix/filter-null-integrations-frontend branch from d8f0e77 to 6479deb Compare March 17, 2026 16:51
Comment on lines +10 to +47
const githubProvider = {
key: 'github',
slug: 'github',
name: 'GitHub',
canAdd: true,
canDisable: false,
features: ['commits'],
metadata: {
aspects: {},
author: 'The Sentry Team',
description: '',
features: [{featureId: 1, featureGate: 'integrations-commits', description: ''}],
issue_url: '',
noun: 'Installation',
source_url: '',
},
setupDialog: {height: 600, url: '', width: 600},
};

const githubIntegration = {
id: '1',
name: 'GitHub',
provider: {
key: 'github',
slug: 'github',
name: 'GitHub',
canAdd: true,
canDisable: false,
features: [],
aspects: {},
},
domainName: 'github.com/test',
icon: null,
accountType: null,
gracePeriodEnd: null,
organizationIntegrationStatus: 'active',
status: 'active',
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we have types or fixtures for these

@ryan953 ryan953 merged commit 39d21f9 into master Mar 17, 2026
63 checks passed
@ryan953 ryan953 deleted the ryan953/fix/filter-null-integrations-frontend branch March 17, 2026 18:00
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants