refactor: Make QueryBlocklistRule an interface for extensibility#19457
refactor: Make QueryBlocklistRule an interface for extensibility#19457abhishekrb19 wants to merge 2 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.
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: