fix: Prevent InvalidTypeIdException when Prometheus metric has 'type'… - #5696
fix: Prevent InvalidTypeIdException when Prometheus metric has 'type'…#5696nagendramohan wants to merge 1 commit into
Conversation
… label Add @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) on PrometheusResult to override the parent DataSourceResult interface's polymorphic type handling. This prevents Jackson from interpreting a metric label named 'type' as the polymorphic type discriminator, which caused InvalidTypeIdException during deserialization. The type dispatch is already handled explicitly via switch statement in ExecuteDirectQueryActionResponse, so polymorphic type annotations are not needed on the concrete class. Resolves opensearch-project#5684 Signed-off-by: Nagendra Mohan <nagendramohan1990@gmail.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
Friendly ping — this fixes a crash when Prometheus metrics contain a field named type (issue #5684). Small change: one annotation + regression test. Happy to address any feedback. |
… label
Add @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) on PrometheusResult to override the parent DataSourceResult interface's polymorphic type handling. This prevents Jackson from interpreting a metric label named 'type' as the polymorphic type discriminator, which caused InvalidTypeIdException during deserialization.
The type dispatch is already handled explicitly via switch statement in ExecuteDirectQueryActionResponse, so polymorphic type annotations are not needed on the concrete class.
Resolves #5684
Description
PromQL queries fail with
InvalidTypeIdExceptionwhen a metric contains a label namedtype. This happens because theDataSourceResultinterface uses
@JsonTypeInfo(property = "type")for polymorphic deserialization, and Jackson interprets the metric'stypelabel as thetype discriminator.
Fix: Add
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)onPrometheusResultto override the parent's polymorphic type handling. The typedispatch is already handled explicitly via switch statement in
ExecuteDirectQueryActionResponse, so annotation-based polymorphism is unnecessary on the concrete class.Includes a regression test with a metric containing
"type": "gauge"label.Related Issues
Resolves #5684
Check List
created.
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check
here.