Fix: TypeError in matchConnection for enterprise connections with no domains#2736
Merged
ankita10119 merged 7 commits intomasterfrom Mar 17, 2026
Merged
Fix: TypeError in matchConnection for enterprise connections with no domains#2736ankita10119 merged 7 commits intomasterfrom
ankita10119 merged 7 commits intomasterfrom
Conversation
There was a problem hiding this comment.
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
domainsto an empty ImmutableList()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.
gyaneshgouraw-okta
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Added
List()as a default fallback tox.get('domains')return x.get('domains', List()).contains(target);This returns an empty Immutable List when
domainsis absent, making.contains()returnfalsesafely instead of throwing.References
Closes #2733
Testing
Manually ran a unit test (
matchConnection.test.js) against the fix to verify the exact regression scenario:core/index.connectionsto return a samlp enterprise connection with no domains field - replicating what the tenant API returns when no domains are configured on the connectionWe 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