Fix: attach data_quality_issues for list payloads in wrapper validation#1151
Conversation
Greptile SummaryThis PR fixes the bug in
Confidence Score: 3/5Not safe to merge as-is — the fix introduces a structural regression that changes the shape of every validated list item. Two P1 findings: the switch to
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["validate_host_metrics(metrics)"] --> B{Is metrics a dict?}
B -- No --> C["Return error with data_quality_issues"]
B -- Yes --> D{"'data' key present and is a list?"}
D -- No --> E["validator.validate_metrics(metrics) — flat/nested path"]
D -- Yes --> F["Loop over data points"]
F --> G{Is data_point a dict?}
G -- No --> H["Append as-is"]
G -- Yes --> I["validator.validate_metrics(data_point) ⚠️ wraps scalar cpu/disk"]
I --> J{"data_quality_issues in validated_point?"}
J -- Yes --> K["Extend all_issues; del from validated_point"]
J -- No --> L["Skip"]
K --> M["Append validated_point"]
L --> M
H --> M
M --> F
F --> N["result = metrics.copy(); result['data'] = validated_data"]
N --> O{any all_issues?}
O -- Yes --> P["result['data_quality_issues'] = all_issues"]
O -- No --> Q["Return result"]
P --> Q
|
| if isinstance(data_point, dict): | ||
| # Validate each data point | ||
| validated_point = validator._validate_flat_metrics(data_point.copy()) | ||
| validated_point = validator.validate_metrics(data_point.copy()) |
There was a problem hiding this comment.
validate_metrics mutates scalar cpu/disk in each list item
Switching from _validate_flat_metrics to validate_metrics fixes issue aggregation, but introduces a structural regression. validate_metrics runs _validate_cpu_metric and _validate_disk_metric on any key named "cpu" or "disk", and both methods return {"raw": <value>, "validated": False} when the input is not a dict (i.e. a plain integer). For a flat data point like {"cpu": 95, "ram": 8589934592, "disk": 50}, the returned point inside validated_data will have cpu and disk replaced with nested dicts instead of their original scalar values — silently changing the shape of every list item in the response.
|
@emefienem review points, CI checks |
VaibhavUpreti
left a comment
There was a problem hiding this comment.
awesome @emefienem merging this for velocity!
|
😤 @emefienem said "I will fix this" and then actually fixed it. Legendary behavior. 👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome. |
🫡 |

Fixes #1113
Describe the changes you have made in this PR -
This PR fixes a bug in
validate_host_metrics()where list-based payloadsdid not properly aggregate and return
data_quality_issuesat the root level.Changes made:
validate_host_metricsvalidate_metricsdata_quality_issuesfrom list items into root responseDemo/Screenshot for feature changes and bug fixes -
Code Understanding and AI Usage
Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?
If you used AI assistance:
Explain your implementation approach:
Checklist before requesting a review
Note: Please check Allow edits from maintainers if you would like us to assist in the PR.