Skip to content

Commit e18a8db

Browse files
fix(cli): Keep regex values intact after a closing paren or quote
Upstream allows a filter to follow ) or a quote with no space, so the preserved-segment check now accepts those too. Refs LOGS-1031 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 99c75de commit e18a8db

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎packages/cli/src/lib/search-query.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ export const SEARCH_SYNTAX_REFERENCE = {
503503
wildcard: "* in values (e.g., message:*timeout*)",
504504
inList: "key:[val1,val2] — matches any value in the list",
505505
regex:
506-
"key://pattern// (logs only, string attributes) — RE2, unanchored, case-sensitive ((?i) to ignore case), max 64 chars, never quoted; ends at the first // followed by whitespace, ) or end of query; negate with !key://pattern//",
506+
"key://pattern// (logs only, string and array attributes) — RE2, unanchored, case-sensitive ((?i) to ignore case), max 64 chars, never quoted; ends at the first // followed by whitespace, ) or end of query; negate with !key://pattern//",
507507
},
508508
filterTypes: [
509509
"text (key:value)",
@@ -572,7 +572,7 @@ const PROJECT_NUMERIC_LIST_RE = /(^|\s)(!?)project:\[(\d+(?:\s*,\s*\d+)*)\]/gi;
572572
*/
573573
const REGEX_FILTER_KEY_SOURCE = String.raw`(?:(?:tags|flags)\[[\w.:-]+(?: *, *(?:string|number|boolean|array))?\]|"[\w.:-]+"|[\w.[\]-]+)(?:\[\*\])?`;
574574
const PRESERVED_SEGMENT_RE = new RegExp(
575-
String.raw`"(?:[^"\\]|\\.)*"|(?<=(?:^|[\s(])!?${REGEX_FILTER_KEY_SOURCE}:)\/\/(?:(?!\/\/(?:[\t\n )]|$))[^\n])+\/\/(?=[\t\n )]|$)`,
575+
String.raw`"(?:[^"\\]|\\.)*"|(?<=(?:^|[\s()"])!?${REGEX_FILTER_KEY_SOURCE}:)\/\/(?:(?!\/\/(?:[\t\n )]|$))[^\n])+\/\/(?=[\t\n )]|$)`,
576576
"g"
577577
);
578578

‎packages/cli/test/lib/search-query.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,12 @@ describe("sanitizeQuery: regex filters", () => {
506506
).toBe("arr[*]://a OR [b,]// tags[k,array][*]://a OR b//");
507507
});
508508

509+
test("passes through a regex right after a closing paren or quote", () => {
510+
expect(
511+
sanitizeQuery('(level:x)message://[a,]// "foo"message://[b,]//')
512+
).toBe('(level:x)message://[a,]// "foo"message://[b,]//');
513+
});
514+
509515
test("throws for OR between regex filters", () => {
510516
expect(() => sanitizeQuery("message://a// OR message://b//")).toThrow(
511517
ValidationError

0 commit comments

Comments
 (0)