Repository navigation
feat: save PromQL queries in filters (port upstream #1830) - #61
Merged
Merged
Conversation
(cherry picked from commit 44bd8db)
Follow-up to the cherry-picked upstream 44bd8db (parseablehq#1830), which adds FilterType::Promql and authorizes PromQL saved filters by dataset name. - Frontend: the /filters list guard only accepted filter|sql|search and rejected the whole list on any unknown entry, so one saved PromQL filter would break Saved log views and the SQL sidebar for everyone who can see it. Accept `promql`, and keep PromQL filters out of the Logs saved-view picker (they are not log views). - Tests: PromQL serde round-trip; list_filters authorizes PromQL by dataset (not by parsing the query as SQL) and hides it without access; PromQL filters require a concrete dataset name (not the `sql` sentinel or path-like names); convert-to-sql rejects PromQL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports upstream parseablehq/parseable@44bd8db7 ("feat: save promql queries in filters", parseablehq#1830). It was cherry-picked with
-x, so the original author and commit are kept. The second commit adds tests and fixes the frontend.Upstream change: adds
FilterType::Promql(serialized as"promql").list_filtersnow authorizes PromQL saved filters by theirstream_name, the same way it handles Search and Filter, and the if/else became an exhaustivematch. Before this, an unknown filter type was rejected on create (400 from serde). A type with no matching branch would also have been left out of the list silently.Ramifications checked
src/handlers/http/promql.rs) needs exactly one dataset fromX-P-Streamorstream, and it authorizes only that dataset. A PromQL query cannot reach metrics in other datasets, so authorizing the saved filter'sstream_namematches what running it would require. Authorizing the query text instead would be wrong:user_auth_for_queryparses SQL table names, so a PromQL query would fail to parse and the filter would be hidden from everyone.stream_nameis always set. It is a requiredStringonFilter.validate_stream_namechecks it as a user-defined dataset name on POST/PUT, so thesqlsentinel, empty names and path-like names are rejected for PromQL. There is a test for this.FilterTypeuse (metastore canonicalization and alias cleanup,preserve_filter_identity,convert_filter_to_sql) only special-casesSQL. PromQL is handled like Search/Filter, and convert-to-sql rejects it. The tool catalog (list_filters/get_filter) goes through the same handlers and needs no change.let Ok(..) else { continue }). A node without this change just ignores PromQL filters and still loads the rest.savedLogViewonly acceptedfilter|sql|search, andlistLogViewsrejects the whole/filtersresponse if any entry fails. One saved PromQL filter would have broken Saved log views and the SQL sidebar's server queries for every user who can see it. Nowpromqlis accepted, and PromQL filters are kept out of the Logs saved-view picker, which would otherwise have listed them as "classic" views of their dataset. The SQL sidebar already ignores non-sqlfilters.Tests
list_filtersreturns a PromQL filter to a session with query access and hides it from one with none. A mutation check confirmed this test fails if PromQL goes through the SQL path. Also tests for PromQLstream_namevalidation and convert-to-sql rejecting PromQL.Ran:
cargo fmt --check,cargo clippy --all-targets(exit 0; the remaining warnings are all in files this PR doesn't touch),cargo test(849 lib tests passed, plus integration tests) withP_BUILD_NO_UI=1. Frontend:npm run format:check,tsc --noEmit,vitest run src(2415 passed).Follow-ups (not in this PR)
GET /filters/{id}(get_internal) checks ownership or admin but not dataset access, for every filter type. This was already the case before this PR.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.