Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(site): quote colon-containing values in filter serialization - #28254

Merged
johnstcn merged 1 commit into
mainfrom
cian/filter-colon-quoting
Aug 18, 2026
Merged

fix(site): quote colon-containing values in filter serialization#28254
johnstcn merged 1 commit into
mainfrom
cian/filter-colon-quoting

Conversation

@johnstcn

@johnstcn johnstcn commented Aug 18, 2026

Copy link
Copy Markdown
Member

stringifyFilter in the shared Filter component 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 backend searchTerms parser 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/stringifyFilter into filterQuery.ts with 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)

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.
@linear-code

linear-code Bot commented Aug 18, 2026

Copy link
Copy Markdown

AIGOV-580

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(":");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self-review: moved to filterQuery.ts so it can be tested properly

@johnstcn
johnstcn marked this pull request as ready for review August 18, 2026 11:07
Copilot AI lite review requested due to automatic review settings August 18, 2026 11:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 parseFilterQuery and stringifyFilter into filterQuery.ts for 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.

@johnstcn
johnstcn requested a review from jeremyruppel August 18, 2026 15:41

@jeremyruppel jeremyruppel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one! 👍

@johnstcn
johnstcn merged commit 962366f into main Aug 18, 2026
58 of 59 checks passed
@johnstcn
johnstcn deleted the cian/filter-colon-quoting branch August 18, 2026 16:01
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants