-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore(aci): handle OrganizationMember.DoesNotExist when getting target #102113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,10 +46,14 @@ def target(action: Action) -> OrganizationMember | Team | str | None: | |
| target_type = action.config.get("target_type") | ||
| if target_type == ActionTarget.USER.value: | ||
| dcga = DataConditionGroupAction.objects.get(action=action) | ||
| return OrganizationMember.objects.get( | ||
| user_id=int(target_identifier), | ||
| organization=dcga.condition_group.organization, | ||
| ) | ||
| try: | ||
| return OrganizationMember.objects.get( | ||
| user_id=int(target_identifier), | ||
| organization=dcga.condition_group.organization, | ||
| ) | ||
| except OrganizationMember.DoesNotExist: | ||
| # user is no longer a member of the organization | ||
| pass | ||
|
Comment on lines
+49
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: 🔍 Detailed AnalysisWhen 💡 Suggested FixModify 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| elif target_type == ActionTarget.TEAM.value: | ||
| try: | ||
| return Team.objects.get(id=int(target_identifier)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: EMAIL Action Missing in Dictionary
The added
elseclause for EMAIL action type creates a logic gap. Whenaction_targetis truthy buttarget_typeis neither USER nor TEAM, the function doesn't return anything from the EMAIL block and falls through to the finalelsestatement (line 48), which tries to accessaction_type_to_string[action_type]. However, EMAIL is not in theaction_type_to_stringdictionary (lines 22-27), causing a KeyError. Theelseclause should be moved inside theif action_target:block to properly handle cases where action_target exists but target_type doesn't match expected values.