Skip to content

fix(provider): prevent heimdall span ID collapse on API errors#71

Merged
minhd-vu merged 4 commits intomainfrom
fix/heimdall-span-id-collapse
May 4, 2026
Merged

fix(provider): prevent heimdall span ID collapse on API errors#71
minhd-vu merged 4 commits intomainfrom
fix/heimdall-span-id-collapse

Conversation

@minhd-vu
Copy link
Copy Markdown
Collaborator

@minhd-vu minhd-vu commented May 4, 2026

Description

When heimdall-api returns a 5xx with a JSON error envelope, the body was decoding into a zero-value struct (ID=0, StartBlock=0, EndBlock=0), causing panoptichain to treat it as a real span and walk +1 per tick.

Changes:

  • Add HTTP status code validation in api.GetJSON before JSON decoding
  • Reject zero-value spans in fetchSpan as defense-in-depth
  • Cap sequential span walking with configurable max_span_lag (default 10) to prevent multi-hour catch-up walks after transient failures

Jira / Linear Tickets

Testing

  • Test A
  • Test B

minhd-vu added 4 commits May 4, 2026 13:13
When heimdall-api returns a 5xx with a JSON error envelope, the body
was decoding into a zero-value struct (ID=0, StartBlock=0, EndBlock=0),
causing panoptichain to treat it as a real span and walk +1 per tick.

Changes:
- Add HTTP status code validation in api.GetJSON before JSON decoding
- Reject zero-value spans in fetchSpan as defense-in-depth
- Cap sequential span walking with configurable max_span_lag (default 10)
  to prevent multi-hour catch-up walks after transient failures
…hecks

- exchange_rates: use api.GetJSON instead of direct http.Get for
  consistent status code validation
- grafana provider: add HTTP status check and 10s timeout to prevent
  silent failures on non-2xx responses
- grafana observer: add array bounds validation before accessing
  frame.Data.Values to prevent panics on malformed responses
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@minhd-vu minhd-vu merged commit c9bae4b into main May 4, 2026
5 of 6 checks passed
@minhd-vu minhd-vu deleted the fix/heimdall-span-id-collapse branch May 4, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant