Skip to content

Decode quoted literals and parse matcher operators before values - #17

Merged
aaraujo merged 1 commit into
mainfrom
fix/logql-quoted-literals
Nov 14, 2026
Merged

aaraujo merged 1 commit into
mainfrom
fix/logql-quoted-literals

Conversation

@aaraujo

@aaraujo aaraujo commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Decode interpreted string literals once before exposing selector and pipeline values in the AST. Quoted service names and literal filters now carry their actual quote/backslash characters. Matcher operators are read from the label prefix, so strings such as a!=b, a=~b and a!~b stay inside the value.

Use the same decoder for quoted pipeline stages, preserve raw-string backslashes and discard raw carriage returns. Support Go simple, octal, hex-byte and Unicode escapes; reject malformed escapes and invalid Unicode. AST values are UTF-8 strings, so byte escapes that do not form valid UTF-8 are rejected explicitly and documented. No dependency or publishing change.

Six new literal regression tests cover all matcher/line-filter operators, shared stages, one-time decoding, Unicode/byte escapes and malformed input. The initial five regressions failed before the fix. Six compatibility corpus cases and its checksum are updated.

Validation:

  • Full tests passed on Rust 1.94.1 and stable.
  • Strict clippy, formatting and docs build passed.
  • Corpus and release adversarial checks passed, including 20,000 mutation rounds.
  • Prior-head src/parser.rs coverage: 94.7% (2,289/2,418 lines), evaluated by the repository's 80% per-file gate using locally installed cargo-llvm-cov 0.6.16. This measurement predates the rebase; the parser body is unchanged. CI remains authoritative.
  • Clean-export scan passed with zero findings.

Reference semantics: Go string literals.

Quoted-regex compatibility

This rejects previously tolerated single-backslash regex escapes inside
interpreted strings. For example, the first form below now fails to parse; the next two are valid:

{app="web"} |~ "5\d\d"
{app="web"} |~ `5\d\d`
{app="web"} |~ "5\\d\\d"

The examples above are query text, before any host-language/JSON escaping.
Consumers should check persisted query/configuration strings for \d, \. and
similar regex escapes; existing strings are not automatically rewritten. Raw
pipeline strings preserve these backslashes. Backtick selector support is
unchanged and remains outside this patch.

Rebased onto current main 0192fa9 at 840f1ce74886af0360977a9b5857fc4f14154098.
The only conflict was the changelog; both the unreleased parser fix and the 0.1.1
license entry are preserved. The new regression file uses current upstream
PackDB Contributors casing. Parser and regression bodies are unchanged.
OSS_CHECK_SCOPE=full scripts/oss-ci.sh checks passes after rebasing, including
source-header checks, formatting, strict lint, full tests, doctests and package
manifest/content checks. This PR does not publish a package.

@aaraujo
aaraujo force-pushed the fix/logql-quoted-literals branch from ac7e9bc to 840f1ce Compare November 11, 2026 02:00
@aaraujo
aaraujo marked this pull request as ready for review November 11, 2026 02:08
@aaraujo
aaraujo merged commit 252d973 into main Nov 14, 2026
8 checks passed
@aaraujo
aaraujo deleted the fix/logql-quoted-literals branch November 14, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant