Repository navigation
Conversation
| elif key == "status": | ||
| try: | ||
| queryset = queryset.filter( | ||
| monitorenvironment__status__in=map_value_to_constant( | ||
| MonitorStatus, value | ||
| ) | ||
| monitorenvironment__status__in=[ | ||
| map_value_to_constant(MonitorStatus, status) for status in value | ||
| ] | ||
| ) | ||
| except ValueError: | ||
| queryset = queryset.none() |
There was a problem hiding this comment.
status:ok filter maps to MonitorStatus.ACTIVE instead of OK
map_value_to_constant rewrites "OK" to "ACTIVE", so status:ok filters monitorenvironment__status=0 (never checked in) instead of 4 (healthy). Remove the OK→ACTIVE alias so status:ok resolves to MonitorStatus.OK.
Evidence
- The new filter calls
map_value_to_constant(MonitorStatus, status)for each token fromtokenize_query. map_value_to_constantdoesif value == "OK": value = "ACTIVE"beforegetattr, sostatus:okbecomesMonitorStatus.ACTIVE(0).MonitorStatus.OKis 4 and is the status set by successful check-ins (mark_ok/ incident resolution);ACTIVEis only the default for new environments.- Result:
status:okmatches never-checked-in envs and excludes healthy OK envs.
Identified by Warden · sentry-backend-bugs · BG9-YVJ
There was a problem hiding this comment.
Fix attempt detected (commit f16cfbc)
The status-filter logic was directly changed, but it still calls map_value_to_constant, so status:ok continues to map to MonitorStatus.ACTIVE instead of MonitorStatus.OK.
The original issue appears unresolved. Please review and try again.
Evaluated by Warden
There was a problem hiding this comment.
Fix attempt detected (commit 0df6dd5)
The status-filter logic was directly changed to use an Exists query, but it still calls map_value_to_constant(MonitorStatus, status), so the OK-to-ACTIVE alias remains and status:ok still maps to ACTIVE.
The original issue appears unresolved. Please review and try again.
Evaluated by Warden
There was a problem hiding this comment.
Fix attempt detected (commit b72554e)
The commit explicitly changes monitor status filtering, but still calls map_value_to_constant(MonitorStatus, status), so the OK-to-ACTIVE alias remains and status:ok continues matching ACTIVE instead of OK.
The original issue appears unresolved. Please review and try again.
Evaluated by Warden
f16cfbc to
0df6dd5
Compare
|
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you add the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
The status search token value is a list of strings, but it was passed to map_value_to_constant as a single string, so .upper() raised an AttributeError (not caught by the ValueError handler) and the status was then passed to an __in lookup as a bare int. Each value is now mapped separately. The helper also remapped ok to ACTIVE (0) instead of MonitorStatus.OK (4), which is fixed. The filter now uses an Exists subquery on the monitor environments already used for sorting and serialization, so it applies to the requested environments and a monitor is never returned more than once. Unknown statuses still return no monitors.
0df6dd5 to
b72554e
Compare
Consolidates the previously separate drafts #127793 and #127813 into one review unit; the code is unchanged from those individually validated drafts. - monitor index no longer silently mis-filters when the OK status maps onto ACTIVE, and filters status through environment-scoped EXISTS instead of a joined membership check - monitor deletion passes the scheduled deletion GUID as the audit log transaction id instead of the rule id Integrated in #130956.
The
statussearch filter on the monitor index had three problems:tokenize_queryreturns each value as a list of strings, but the list was passed tomap_value_to_constant, which calls.upper()on it.status:okraised anAttributeErrorthat the surroundingexcept ValueErrordid not catch.map_value_to_constantremappedoktoMonitorStatus.ACTIVE(0) instead ofMonitorStatus.OK(4), sostatus:okwould have matched the wrong monitor environments. It has no other caller.monitorenvironmentdirectly. That can return the same monitor several times in paginated results, and as a separatefilter()call it does not use the same joined row as theenvironmentparam.Each value is now mapped on its own,
okmaps toOK, and the filter is anExistssubquery on the same monitor environment queryset used for sorting and serializing. Status therefore applies to the requested environments (all organization environments when none are given), and a monitor is returned once.status:a status:bmatches either. Unknown statuses still return an empty queryset.Not tested here: the endpoint tests need the database, so this relies on CI. There is no existing test for the
statusquery filter.