This repository was archived by the owner on Sep 3, 2025. It is now read-only.
fix(service): get_by_name_or_default no longer works if name wasn't found#6027
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses an issue where get_by_name_or_default was not returning the correct value when a name wasn’t found by refactoring the logic across multiple services and updating error messages to reflect the new expected output.
- Refactored get_by_name_or_default functions to combine the existence and name-check conditions.
- Updated ValidationError messages in various services to ensure consistency.
- Added new tests to verify behavior for both found and default cases across projects, organizations, incidents, and cases.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/signal/test_signal_service.py | Updated assertions on error messages for signal creation/update. |
| tests/project/test_project_service.py | Minor formatting update and added tests for get_by_name_or_default. |
| tests/organization/test_organization_service.py | Added tests for get_by_name_or_default on organization service. |
| tests/incident_type/test_incident_type_service.py | Added tests for get_by_name_or_default for incident types. |
| tests/incident_priority/test_incident_priority_service.py | Added tests for incident priority get_by_name_or_default. |
| tests/case_type/test_case_type_service.py | Added tests for case type get_by_name_or_default. |
| src/dispatch/project/service.py | Simplified get_by_name_or_default logic. |
| src/dispatch/organization/service.py | Similar refactoring for get_by_name_or_default. |
| src/dispatch/incident/type/service.py | Refactored ValidationError formatting and lookup logic. |
| src/dispatch/incident/severity/service.py | Consistent changes to error-handling and lookup in get_by_name_or_default. |
| src/dispatch/incident/priority/service.py | Refactored similar to other incident service modules. |
| src/dispatch/case/type/service.py | Simplified nested checks in get_by_name_or_default. |
| src/dispatch/case/severity/service.py | Adjusted error messages and conditional logic in get_by_name_or_default. |
| src/dispatch/case/priority/service.py | Reformatted ValidationError messages and refactored lookup logic. |
aaronherman
approved these changes
Jun 2, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR addresses an issue where
get_by_name_or_defaultwas throwing a ValidationError when a name wasn’t found by refactoring the logic across multiple services and updating error messages to reflect the new expected output.get_by_name_or_defaultfunctions to combine the existence and name-check conditions.