Skip to content

feat(QueryEditor): validate ad-hoc filters against via known field names from field_names request#635

Merged
arturminchukov merged 1 commit into
mainfrom
fix-filter-out-in
May 11, 2026
Merged

feat(QueryEditor): validate ad-hoc filters against via known field names from field_names request#635
arturminchukov merged 1 commit into
mainfrom
fix-filter-out-in

Conversation

@arturminchukov
Copy link
Copy Markdown
Member

@arturminchukov arturminchukov commented May 8, 2026

Related issue: #626
Follow-up: 7cac781

Describe Your Changes

Added highlighting of field names that were added via some transformation functions, such as unpack_json, unpack_logfmt, and so on.
image

Checklist

The following checks are mandatory:


Summary by cubic

Validate ad‑hoc filters in Explore by checking filter keys against known field names from field_names. Mark filters that target computed fields and let users move them into the query to avoid empty or incorrect results.

  • New Features

    • Show ad‑hoc filter chips with a warning icon and tooltip when the field isn’t in source data; actions: Move to query, Delete; shown only in Explore.
    • Validate by fetching field names via field_names, scoped by bucketed time range (day/week/month/year) and streamFilters; results cached with LRU. On request errors or unresolved variables, filters default to valid.
  • Refactors

    • Editor stores ad‑hoc filters as structured query.adHocFilters; they serialize to extraFilters only at request time. Backend API unchanged.
    • Updated toggleQueryFilter to add/remove structured filters; added queryHasFilter so Logs viewer “Filter for/out” actions keep working.
    • Added serializeAdHocFilters, formatAdHocFilterLabel, and bucketTimeRange; language_provider now always sets limit.

Written for commit cd197fc. Summary will update on new commits.

@arturminchukov arturminchukov self-assigned this May 8, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

4 issues found across 13 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/components/QueryEditor/useAdHocFilterValidation.ts">

<violation number="1" location="src/components/QueryEditor/useAdHocFilterValidation.ts:69">
P2: Clear `known` on cache miss before fetching; otherwise validation can use stale field-name data from a previous query context.</violation>

<violation number="2" location="src/components/QueryEditor/useAdHocFilterValidation.ts:91">
P1: Async field-list responses are not guarded against out-of-order completion, so stale requests can overwrite validation state for newer filters/time ranges.</violation>
</file>

<file name="src/datasource.ts">

<violation number="1" location="src/datasource.ts:209">
P2: `queryHasFilter` compares unescaped values against escaped stored filters, so active filters with special characters are not recognized.</violation>

<violation number="2" location="src/datasource.ts:232">
P1: Removing the `extraFilters` fallback breaks backward compatibility for existing queries that still store ad-hoc filters only in `extraFilters`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread src/components/QueryEditor/useAdHocFilterValidation.ts
Comment thread src/datasource.ts
Comment thread src/components/QueryEditor/useAdHocFilterValidation.ts
Comment thread src/datasource.ts Outdated
Copy link
Copy Markdown
Contributor

@dmitryk-dk dmitryk-dk left a comment

Choose a reason for hiding this comment

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

Just check one comment where the dependecy missing

@arturminchukov arturminchukov merged commit 7028d56 into main May 11, 2026
3 of 4 checks passed
@arturminchukov arturminchukov deleted the fix-filter-out-in branch May 11, 2026 12:12
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.

2 participants