fix(site): quote colon-containing values in filter serialization - #28254
Merged
Merged
Conversation
stringifyFilter only quoted values containing spaces, so filter values like RFC 3339 timestamps (2026-08-16T20:42:00Z) were emitted unquoted and the backend query parser rejected their colons. Quote values containing colons too; they were never valid unquoted. Extract parseFilterQuery/stringifyFilter into filterQuery.ts with unit tests.
johnstcn
commented
Aug 18, 2026
Comment on lines
+22
to
+25
| // Values containing spaces or colons must be quoted: the backend query | ||
| // parser splits unquoted elements on ':' and rejects more than one colon. | ||
| const needsQuotes = (value: string): boolean => | ||
| value.includes(" ") || value.includes(":"); |
Member
Author
There was a problem hiding this comment.
self-review: This is the meat of the change.
Comment on lines
-105
to
-137
| const parseFilterQuery = (filterQuery: string): FilterValues => { | ||
| if (filterQuery === "") { | ||
| return {}; | ||
| } | ||
|
|
||
| const result: FilterValues = {}; | ||
| const keyValuePair = /(\w+):"([^"]+)"|(\w+):(\S+)/g; | ||
|
|
||
| for (const match of filterQuery.matchAll(keyValuePair)) { | ||
| const key = match[1] ?? match[3]; | ||
| const value = match[2] ?? match[4]; | ||
| if (key && value) { | ||
| result[key] = value; | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| }; | ||
|
|
||
| const stringifyFilter = (filterValue: FilterValues): string => { | ||
| let result = ""; | ||
|
|
||
| for (const key in filterValue) { | ||
| const value = filterValue[key]; | ||
| if (value) { | ||
| const needsQuotes = value.includes(" "); | ||
| result += needsQuotes ? `${key}:"${value}" ` : `${key}:${value} `; | ||
| } | ||
| } | ||
|
|
||
| return result.trim(); | ||
| }; | ||
|
|
Member
Author
There was a problem hiding this comment.
self-review: moved to filterQuery.ts so it can be tested properly
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes filter query re-serialization in the shared Filter component so values that contain colons (notably RFC 3339 timestamps) remain valid for the backend search parser when the query is regenerated, and it extracts the parsing/serialization helpers into a dedicated module with unit tests.
Changes:
- Updated filter serialization to quote values containing
:in addition to spaces. - Extracted
parseFilterQueryandstringifyFilterintofilterQuery.tsfor reuse and isolation. - Added Vitest unit tests, including a quoted timestamp round-trip.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| site/src/components/Filter/filterQuery.ts | New shared helpers for parsing and serializing filter query strings, including colon-aware quoting. |
| site/src/components/Filter/filterQuery.test.ts | Unit tests validating quoting behavior and parse/stringify round-trips (including RFC 3339 timestamps). |
| site/src/components/Filter/Filter.tsx | Switched the Filter component to use the extracted filterQuery helpers instead of inline implementations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
stringifyFilterin the sharedFiltercomponent only quoted values containing spaces. Filter values like RFC 3339 timestamps (2026-08-16T20:42:00Z) contain colons but no spaces, so when any filter was edited and the whole query re-serialized, the timestamp went out unquoted and the backendsearchTermsparser rejected it (Query element ... can only contain 1 ':').Quote values containing colons as well; they were never valid unquoted because the backend parser already rejects them. Extract
parseFilterQuery/stringifyFilterintofilterQuery.tswith unit tests, including a round-trip of quoted timestamps.Part of AIGOV-580
Generated by Coder Agents on behalf of @johnstcn.$
Stack: #28254 (filterQuery fix) \u2192 #28255 (component) \u2192 #28256 (sessions page)