fix: handle empty organization data correctly (CM-1113)#4032
Merged
Conversation
Signed-off-by: Uroš Marolt <uros@marolt.me>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts organization upsert behavior to correctly handle cases where domain normalization invalidates previously verified organization identities, avoiding incorrect lookups/creation attempts with now-empty identity data.
Changes:
- Make
verifiedIdentitiesre-assignable and re-derive it after domain normalization + identity cleanup. - Skip further processing (return
undefined) when normalization removes all verified identities and there is nodisplayName.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Uroš Marolt <uros@marolt.me>
mbani01
approved these changes
Apr 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.
Note
Medium Risk
Changes organization upsert behavior to return
undefined(skip) instead of throwing when verified identities are lost during domain normalization, which can affect whether organizations are created/updated in ingestion flows.Overview
Improves
findOrCreateOrganizationto better handle empty/invalid identity data by defaultingdata.identitiesto an empty array and re-computingverifiedIdentitiesafter domain normalization/filtering.If normalization removes all verified identities and there is no
displayName, the function now logs and returnsundefined(skips processing) instead of erroring, preventing failures on malformed organization inputs.Reviewed by Cursor Bugbot for commit ae719a8. Bugbot is set up for automated code reviews on this repo. Configure here.