Skip to content

fix(logs): stop hasToken and hasAny/hasAll 500s on separator and big int needles - #12261

Merged
tushar-signoz merged 1 commit into
mainfrom
fix-has-function-bugs
Jul 24, 2026
Merged

fix(logs): stop hasToken and hasAny/hasAll 500s on separator and big int needles#12261
tushar-signoz merged 1 commit into
mainfrom
fix-has-function-bugs

Conversation

@tushar-signoz

@tushar-signoz tushar-signoz commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Two pre-existing logs-filter 500s in the has-family functions, each turned into correct behavior.

What

  • hasToken separator/whitespace needle → clean 400 (was 500, both modes). A needle like user_id, an IP, or a UUID contains a ClickHouse token separator; CH rejects it (code 36, "Needle must not contain whitespace or separator characters") and it surfaced as a 500. Now validated up front in conditionForHasToken — the single choke point both the legacy and JSON body paths flow through — returning a 400 that points at CONTAINS for multi-token search.
  • hasAny/hasAll on a quoted integer ≥ 2³² → real match (was 500, legacy flag-off only). clickhouse-go binds the needle as a concrete Array(UInt64), which has no supertype with the Array(Nullable(Int64)) extraction that hasAny/hasAll must unify (code 386, NO_COMMON_TYPE). The needle array is now CAST(… AS Array(Int64)) to match the extraction.

Guardrails

  • hasToken: one guard at the single choke point; no SQL change for valid single-token needles.
  • hasAny/hasAll: the CAST is scoped to the Int64 element type and the legacy path only — JSON mode already handles big ints via typed body_v2 columns, so it's untouched. String/Float64 SQL is unchanged.
  • Scalar has() and the scalar OR-fallback are value-level coercion and don't hit the array supertype, so they're unaffected (verified they don't 386).

Notes

  • Both bugs are pre-existing, not tied to the recent has-family revamp.
  • The big-int fix was verified against the exact target ClickHouse 25.12.5: reproduced code 386 with a concrete Array(UInt64) needle for both hasAny/hasAll, confirmed the CAST … AS Array(Int64) returns the correct match, and confirmed the scalar IN/= fallback does not 386.

Testing

  • Go unit tests: hasToken separator/whitespace needles → 400; legacy Int64 hasAny/hasAll big-int needles assert the CAST(… AS Array(Int64)) in the generated SQL.
  • Integration regression tests flipped from capturing the 500 to the fixed behavior: hasToken separator → 400 (legacy + JSON); hasAny/hasAll big int → 200 with an exact single match (renamed …_errors…_matches).
  • make go-lint → 0 issues; make py-fmt / make py-lint clean.

@github-actions github-actions Bot added the bug Something isn't working label Jul 24, 2026
@tushar-signoz tushar-signoz self-assigned this Jul 24, 2026
@tushar-signoz tushar-signoz added the safe-to-integrate Run integration tests label Jul 24, 2026
…int needles

hasToken(body, <needle>) returned a 500 whenever the needle contained a
token separator or whitespace (ClickHouse code 36). Validate the needle
up front in conditionForHasToken (the single choke point for both legacy
and JSON modes) and return a clean 400 pointing at CONTAINS instead.

hasAny/hasAll on a legacy body array returned a 500 for a quoted integer
needle >= 2^32: clickhouse-go binds it as a concrete Array(UInt64), which
has no supertype with the Array(Nullable(Int64)) extraction that the
function must unify (code 386). CAST the needle array to Array(Int64) to
match the extraction. Scalar has() and the scalar OR-fallback are
value-level and unaffected.
@tushar-signoz
tushar-signoz force-pushed the fix-has-function-bugs branch from e493af1 to e905af3 Compare July 24, 2026 11:22
@tushar-signoz
tushar-signoz marked this pull request as ready for review July 24, 2026 11:24
@tushar-signoz tushar-signoz added safe-to-integrate Run integration tests and removed safe-to-integrate Run integration tests labels Jul 24, 2026
@tushar-signoz
tushar-signoz added this pull request to the merge queue Jul 24, 2026
Merged via the queue into main with commit 973429a Jul 24, 2026
100 checks passed
@tushar-signoz
tushar-signoz deleted the fix-has-function-bugs branch July 24, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working safe-to-integrate Run integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants