Skip to content

proxy: normalize wrapped Loki responses when resultType is missing#222

Merged
szibis merged 2 commits intomainfrom
ss/fix-missing-resulttype
Apr 20, 2026
Merged

proxy: normalize wrapped Loki responses when resultType is missing#222
szibis merged 2 commits intomainfrom
ss/fix-missing-resulttype

Conversation

@szibis
Copy link
Copy Markdown
Collaborator

@szibis szibis commented Apr 20, 2026

Summary

This fixes intermittent Grafana Loki datasource failures reporting no resultType found in Logs Drilldown.

Root cause was wrapAsLokiResponse passing backend payloads through even when data.resultType was missing (or when payloads used top-level results). Grafana's Loki plugin then failed to decode those responses.

Changes

  • normalize wrapped payloads to always provide Loki data.resultType (fallback from call context)
  • ensure Loki data.result exists (fallback empty array)
  • map top-level results into Loki result while keeping legacy results for compatibility
  • add regression tests for both payload shapes

Validation

  • go test ./internal/proxy -count=1
  • manual Grafana reproduction showed failing datasource query responses with error: no resultType found from plugin

@github-actions github-actions bot added size/M Medium change scope/proxy Proxy core scope/tests Tests labels Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 20, 2026

PR Quality Report

Compared against base branch main.

Coverage and tests

Signal Base PR Delta
Test count 1807 1809 2
Coverage 89.3% 89.3% 0.0% (stable)

Compatibility

Track Base PR Delta
Loki API 100.0% 11/11 (100.0%) 0.0% (stable)
Logs Drilldown 100.0% 17/17 (100.0%) 0.0% (stable)
VictoriaLogs 100.0% 11/11 (100.0%) 0.0% (stable)

Compatibility components

Track Component Base PR Delta
Loki API label_values 2/2 (100.0%) 2/2 (100.0%) 0.0% (stable)
Loki API labels 4/4 (100.0%) 4/4 (100.0%) 0.0% (stable)
Loki API metrics 2/2 (100.0%) 2/2 (100.0%) 0.0% (stable)
Loki API otel 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
Loki API query_range 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
Loki API series 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
Logs Drilldown detected_fields 11/11 (100.0%) 11/11 (100.0%) 0.0% (stable)
Logs Drilldown label_values 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
Logs Drilldown level_volume 2/2 (100.0%) 2/2 (100.0%) 0.0% (stable)
Logs Drilldown patterns 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
Logs Drilldown service_logs 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
Logs Drilldown service_selection 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
VictoriaLogs detected_fields 4/4 (100.0%) 4/4 (100.0%) 0.0% (stable)
VictoriaLogs field_values 3/3 (100.0%) 3/3 (100.0%) 0.0% (stable)
VictoriaLogs index_stats 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
VictoriaLogs stream_translation 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
VictoriaLogs synthetic_labels 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)
VictoriaLogs volume_range 1/1 (100.0%) 1/1 (100.0%) 0.0% (stable)

Performance smoke

Lower CPU cost (ns/op) is better. Lower benchmark memory cost (B/op, allocs/op) is better. Higher throughput is better. Lower load-test memory growth is better. Benchmark rows are medians from repeated samples.

Signal Base PR Delta
QueryRange cache-hit CPU cost 1277.0 ns/op 1286.0 ns/op +0.7% (stable)
QueryRange cache-hit memory 200.0 B/op 200.0 B/op 0.0% (stable)
QueryRange cache-hit allocations 7.0 allocs/op 7.0 allocs/op 0.0% (stable)
QueryRange cache-bypass CPU cost 1621.0 ns/op 1628.0 ns/op +0.4% (stable)
QueryRange cache-bypass memory 271.0 B/op 270.0 B/op -0.4% (stable)
QueryRange cache-bypass allocations 7.0 allocs/op 7.0 allocs/op 0.0% (stable)
Labels cache-hit CPU cost 681.5 ns/op 682.4 ns/op +0.1% (stable)
Labels cache-hit memory 48.0 B/op 48.0 B/op 0.0% (stable)
Labels cache-hit allocations 3.0 allocs/op 3.0 allocs/op 0.0% (stable)
Labels cache-bypass CPU cost 817.7 ns/op 840.1 ns/op +2.7% (stable)
Labels cache-bypass memory 53.0 B/op 53.0 B/op 0.0% (stable)
Labels cache-bypass allocations 3.0 allocs/op 3.0 allocs/op 0.0% (stable)
High-concurrency throughput 131468.0 req/s 113525.0 req/s -13.6% (stable)
High-concurrency memory growth 0.4 MB 0.4 MB 0.0% (stable)

State

  • Coverage, compatibility, and sampled performance are reported here from the same PR workflow.
  • This is a delta report, not a release gate by itself. Required checks still decide merge safety.
  • Performance is a smoke comparison, not a full benchmark lab run.
  • Delta states use the same noise guards as the quality gate (percent + absolute + low-baseline checks), so report labels match merge-gate behavior.

@szibis szibis force-pushed the ss/fix-missing-resulttype branch from 5472cfa to c0cf92a Compare April 20, 2026 15:37
@github-actions github-actions bot added size/M Medium change scope/docs Documentation and removed size/M Medium change labels Apr 20, 2026
@szibis szibis merged commit 61236c2 into main Apr 20, 2026
45 of 46 checks passed
@szibis szibis deleted the ss/fix-missing-resulttype branch April 20, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/docs Documentation scope/proxy Proxy core scope/tests Tests size/M Medium change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant