refactor: Make QueryBlocklistRule an interface for extensibility#19457
refactor: Make QueryBlocklistRule an interface for extensibility#19457abhishekrb19 wants to merge 5 commits into
Conversation
FrankChen021
left a comment
There was a problem hiding this comment.
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 1 |
| P3 | 0 |
| Total | 1 |
Reviewed 7 of 7 changed files.
This is an automated review by Codex GPT-5.5
| * {@link org.apache.druid.server.broker.BrokerDynamicConfig} can detect changes correctly. | ||
| */ | ||
| public class QueryBlocklistRule | ||
| @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = DefaultQueryBlocklistRule.class) |
There was a problem hiding this comment.
[P2] Fail unknown blocklist rule types instead of defaulting
Using defaultImpl = DefaultQueryBlocklistRule.class makes Jackson use the default rule not only when type is absent, but also when a non-empty type id cannot be resolved. For the new extension point, a broker or coordinator that lacks a registered custom rule subtype can silently deserialize that rule as DefaultQueryBlocklistRule; with Druid's unknown-property-tolerant mapper, extension-specific fields are ignored and any standard fields such as dataSources can turn into a broader block than intended. Please distinguish the legacy missing-type case from an unrecognized explicit type, so unknown extension rules fail fast rather than being interpreted as default rules.
There was a problem hiding this comment.
Addressed in this commit by adding a StrictTypeIdResolver similar to DimensionSchema
|
@mshahid6 want to take a look here? |
FrankChen021
left a comment
There was a problem hiding this comment.
I rechecked the follow-up on QueryBlocklistRule type-id handling. The latest change uses StrictTypeIdResolver, preserves legacy missing-type defaulting, and adds coverage for missing, explicit default, and unknown explicit types. This addresses the previous concern; no inline reply is needed.
Reviewed 7 of 7 changed files.
This is an automated review by Codex GPT-5.5
|
LGTM, do we need to update the docs too? |
|
Thanks @mshahid6! Given that this is already backward compatible without type, I was thinking we can leave the docs as-is for now and include some notes about the |
|
I went ahead and added some doc updates for completeness - ptal |
FrankChen021
left a comment
There was a problem hiding this comment.
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 0 |
| P3 | 1 |
| Total | 1 |
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 0 |
| P3 | 1 |
| Total | 1 |
Reviewed 8 of 8 changed files.
This is an automated review by Codex GPT-5.5
|
|
||
| ##### Custom types (extensions) | ||
|
|
||
| Extensions can register additional rule types by adding Jackson subtypes to the `QueryBlocklistRule` interface. A custom rule is selected by setting `"type"` to its registered name: |
There was a problem hiding this comment.
[P3] Scope the matching semantics to the default rule type
After introducing custom QueryBlocklistRule types, the following Rule matching behavior section still reads as if every blocklist rule must use datasource/query-type/context criteria with AND semantics and at least one of those criteria. The interface now lets extensions define arbitrary matches logic and fields, so this is only guaranteed for the built-in default rule. Please scope those bullets to the default type or add wording that custom types define their own matching behavior.
There was a problem hiding this comment.
Thanks - updated the docs to clarify this in the latest commit.
FrankChen021
left a comment
There was a problem hiding this comment.
I rechecked the follow-up on the docs scoping comment. The latest docs move the default-rule matching bullets under the default type and explicitly state that custom types define their own matching semantics, so no inline reply is needed.
Reviewed 8 of 8 changed files.
This is an automated review by Codex GPT-5.5
Summary
QueryBlocklistRulefrom a concrete class to an interface with two methods:getRuleName()andmatches(Query<?>).DefaultQueryBlocklistRulewith a default impl on the interface@JsonTypeInfo(defaultImpl = DefaultQueryBlocklistRule.class)so existing JSON configs without a "type" field continue to deserialize correctly.Motivation
The current blocklist logic is fixed to datasource/queryType/context matching. Making it an interface allows adding new rule types (e.g., regex-based, time-window-based, user-based) without modifying the existing code.
This PR has: