Repository navigation
fix[frontend+backend](alerts): 'Row to filters' no longer breaks the alert list with invalid filters (#2968) - #2974
Merged
Merged
Conversation
…s; invalid filters 400 not 500 (#2968)
❌ Go dependencies check failedThere are outdated Go dependencies, or modules that could not be inspected. Script output |
🛑 AI review — Blocking issuesOne or more high/critical issues can break things and must be fixed before merging. Details below. ✅
|
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.
fixfrontend+backend: "Row to filters" no longer breaks the alert list with invalid filters (#2968)
Problem
In Threat Management → Alerts, the funnel icon ("Row to filters") lists every
column of an alert with its checkbox checked by default. Clicking "Apply filters"
with that default selection turned every filter into
IS_ONE_OF, but onlywrapped the value in a list when it was a non-empty string. So:
echoes IS_ONE_OF 0(bare number)adversary IS_ONE_OF {host: ...}(object)impact IS_ONE_OF {confidentiality: ...}(object)target IS_ONE_OF(null / empty)were sent to the backend, where
FilterType.validate()asserts thatIS_ONE_OF/IS_NOT_ONE_OFvalues are aList. The failure surfaced as a500 (not a 400), so the search failed and the alerts page stayed in a
broken state (every later tab/sort/page search failed) until a full reload.
Fix
Frontend (
row-to-filters.component.ts) — make the emitted filters always valid:type === OBJECT, e.g.target,adversary,impact)are offered unchecked by default (their value is a nested object that
cannot be a single filter value). The user can still tick them, but then the
value is sanitized away rather than crashing the list.
applyFilter()now runs every value throughsanitizeFilterValue(), whichnormalizes scalars (string/number) into a single-element list and returns
null(→ filter dropped) for the placeholder-, booleans, objects, andempty collections. This is the same shape the backend
FilterTypeexpects.Backend (
SearchUtil.toQuery) — fail fast with the right status:invalid filter (e.g.
IS_ONE_OFwith a non-list value) now throws anApiException(HTTP 400, via the existing global handler) instead of ageneric
RuntimeException(HTTP 500) after the query was half-built.FilterType.validate()uses SpringAssert(which throwsIllegalArgumentException), so the upfront loop converts that to the 400ApiException. The per-operatorbuild*methods re-validate unchanged.This matches the "UI must not offer an action that only 500s / 400s" principle:
the default selection now produces only valid filters, and any malformed filter
that does reach the backend is reported as a 400, not a 500.
Tests
New
SearchUtilInvalidFilterTest(JUnit, alongside the existingSearchUtilFlattenedTest): object / null / scalarIS_ONE_OF(andIS_NOT_ONE_OF) all throwApiExceptionwithBAD_REQUEST; a proper liststill builds. Existing
SearchUtilFlattenedTeststill passes.Files
frontend/.../row-to-filters.component.tsbackend/.../service/elasticsearch/SearchUtil.javabackend/.../service/elasticsearch/SearchUtilInvalidFilterTest.java(new)Fixes #2968