-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(autofix): Remove unconfigured projects gate and remove code mapping repos fallback #113077
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
Open
srest2021
wants to merge
12
commits into
master
Choose a base branch
from
srest2021/fix-empty-repos-fallback
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+165
−170
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ebae676
fix(autofix): Fall back to code mappings when preference has empty repos
srest2021 2c40534
tests
srest2021 ebcb65a
fix test ordering
srest2021 6e74c18
fix typing
srest2021 3192866
fix(autofix): Add type annotations to fix mypy errors in seer_rpc.py
srest2021 c868880
remove code mappings fallback in trigger autofix
srest2021 c525212
small fixes
srest2021 bf4bd0e
refactor
srest2021 a76ae51
fix docstring
srest2021 acfb22f
test(autofix): Fix endpoint tests for removed code mapping fallback
srest2021 0cf70d0
fix test
srest2021 c4109f0
cleaning up
srest2021 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -734,7 +734,7 @@ def _build_automation_handoff( | |
| ) | ||
|
|
||
|
|
||
| def read_preference_from_sentry_db(project: Project) -> SeerProjectPreference | None: | ||
| def read_preference_from_sentry_db(project: Project) -> SeerProjectPreference: | ||
| """Read a single project's Seer preferences from Sentry DB. | ||
|
|
||
| For now, should only be used under feature flag `organizations:seer-project-settings-read-from-sentry`.""" | ||
|
|
@@ -749,12 +749,6 @@ def read_preference_from_sentry_db(project: Project) -> SeerProjectPreference | | |
| if (repo_def := build_repo_definition_from_project_repo(project_repo)) is not None | ||
| ] | ||
|
|
||
| has_configured_options = any( | ||
| ProjectOption.objects.isset(project, key) for key in SEER_PROJECT_PREFERENCE_OPTION_KEYS | ||
| ) | ||
| if not repo_definitions and not has_configured_options: | ||
| return None | ||
|
|
||
| return SeerProjectPreference( | ||
| organization_id=project.organization_id, | ||
| project_id=project.id, | ||
|
|
@@ -767,7 +761,7 @@ def read_preference_from_sentry_db(project: Project) -> SeerProjectPreference | | |
|
|
||
| def bulk_read_preferences_from_sentry_db( | ||
| organization_id: int, project_ids: list[int] | ||
| ) -> dict[int, SeerProjectPreference | None]: | ||
| ) -> dict[int, SeerProjectPreference]: | ||
| """Bulk read Seer preferences from Sentry DB. | ||
|
|
||
| For now, should only be used under feature flag `organizations:seer-project-settings-read-from-sentry`.""" | ||
|
|
@@ -793,15 +787,8 @@ def bulk_read_preferences_from_sentry_db( | |
| for key in SEER_PROJECT_PREFERENCE_OPTION_KEYS | ||
| } | ||
|
|
||
| result: dict[int, SeerProjectPreference | None] = {} | ||
| result: dict[int, SeerProjectPreference] = {} | ||
| for project in projects: | ||
| has_configured_options = any( | ||
| project_options[key][project.id] is not None | ||
| for key in SEER_PROJECT_PREFERENCE_OPTION_KEYS | ||
| ) | ||
| if project.id not in repo_definitions_by_project and not has_configured_options: | ||
| result[project.id] = None | ||
| continue | ||
|
|
||
| def _get_project_option(key: str) -> Any: | ||
| value = project_options[key][project.id] | ||
|
sentry[bot] marked this conversation as resolved.
|
||
|
|
@@ -831,7 +818,7 @@ def bulk_read_preferences( | |
| Always returns ``dict[int, SeerProjectPreference | None]`` regardless of the | ||
| underlying read path (Sentry DB or Seer API).""" | ||
| if features.has("organizations:seer-project-settings-read-from-sentry", organization): | ||
| return bulk_read_preferences_from_sentry_db(organization.id, project_ids) | ||
| return bulk_read_preferences_from_sentry_db(organization.id, project_ids) # type: ignore[return-value] | ||
|
Member
Author
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. Again mypy. Return type here is dict[int, SeerProjectPreference] so I think it's ok to override mypy |
||
|
|
||
| raw = bulk_get_project_preferences(organization.id, project_ids) | ||
| tuning_by_id = ProjectOption.objects.get_value_bulk_id( | ||
|
|
@@ -887,8 +874,7 @@ def has_project_connected_repos( | |
|
|
||
| has_repos = False | ||
| if features.has("organizations:seer-project-settings-read-from-sentry", organization): | ||
| preference = read_preference_from_sentry_db(project) | ||
| has_repos = bool(preference and preference.repositories) | ||
| has_repos = bool(read_preference_from_sentry_db(project).repositories) | ||
| else: | ||
| try: | ||
| preference = get_project_seer_preferences(project.id).preference | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
This renaming stuff is due to mypy. read_preference_from_sentry_db guarantees SeerProjectPreference but get_project_seer_preferences can return None. I'll just rename the Seer API call result since it'll get removed soon.