Skip to content

Fix: TypeError in matchConnection for enterprise connections with no domains#2736

Merged
ankita10119 merged 7 commits intomasterfrom
SDK-7978
Mar 17, 2026
Merged

Fix: TypeError in matchConnection for enterprise connections with no domains#2736
ankita10119 merged 7 commits intomasterfrom
SDK-7978

Conversation

@ankita10119
Copy link
Contributor

@ankita10119 ankita10119 commented Mar 9, 2026

Changes

Added List() as a default fallback to x.get('domains')

return x.get('domains', List()).contains(target);

This returns an empty Immutable List when domains is absent, making .contains() return false safely instead of throwing.

References

Closes #2733

Testing

Manually ran a unit test (matchConnection.test.js) against the fix to verify the exact regression scenario:

  • Mocked core/index.connections to return a samlp enterprise connection with no domains field - replicating what the tenant API returns when no domains are configured on the connection
  • Called matchConnection with a valid email and asserted it does not throw

We wrote a test to reproduce the issue. Without the fix applied, the test throws TypeError: Cannot read properties of undefined (reading ‘contains’). With the fix, it passes cleanly.

Checklist

@ankita10119 ankita10119 requested a review from a team as a code owner March 9, 2026 18:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a runtime TypeError in matchConnection when an enterprise connection payload omits the domains field (as can happen when no domains are configured), ensuring the lookup safely returns no match instead of throwing.

Changes:

  • Default domains to an empty Immutable List() before calling .contains().
  • Add a regression unit test covering the “enterprise connection with no domains” scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/connection/enterprise.js Prevents .contains() from being called on undefined by providing an empty List() fallback for missing domains.
src/__tests__/connection/enterprise/matchConnection.test.js Adds a Jest regression test verifying matchConnection does not throw when domains is absent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Refactor test to capture result of matchConnection call.
@ankita10119 ankita10119 merged commit a78660f into master Mar 17, 2026
5 checks passed
@ankita10119 ankita10119 deleted the SDK-7978 branch March 17, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error thrown for enterprise connection with no domains configured

3 participants