Skip to content

Fixes a panic in the outputs.heartbeat plugin introduced in v1.38.0.#18565

Closed
hklhai wants to merge 1 commit into
influxdata:masterfrom
hklhai:fix-outputs-heartbeat-panic
Closed

Fixes a panic in the outputs.heartbeat plugin introduced in v1.38.0.#18565
hklhai wants to merge 1 commit into
influxdata:masterfrom
hklhai:fix-outputs-heartbeat-panic

Conversation

@hklhai
Copy link
Copy Markdown

@hklhai hklhai commented Mar 18, 2026

Summary

Fix a panic in the outputs.heartbeat plugin introduced in v1.38.0.

The issue was caused by unsafe type assertions in snapshot():

entry["buffer_limit"].(int64)
entry["buffer_size"].(int64)

This could lead to runtime panics when:

  • fields are missing
  • values are not int64 (e.g. float64 from decoded metrics)

The fix replaces these assertions with safe type checks and falls back
to a default buffer_fullness of 1.0 when values are invalid.

Additionally, selfstat.Metrics() is now wrapped in a package-level variable
to allow proper mocking in unit tests, improving testability.

Related issues

resolves #18559

…etrics

Signed-off-by: hklhai <hkhai@outlook.com>
@telegraf-tiger
Copy link
Copy Markdown
Contributor

@srebhan
Copy link
Copy Markdown
Member

srebhan commented Mar 18, 2026

@hklhai your PR only shadows the real issue (see PR #18568). We know that a internal_write metric must contain the buffer-size and buffer-limit and those fields must be of type int64. That's why a raw type assertion makes sense because if those conditions are not true there is an internal programming error.

Therefore I would prefer my PR over yours.

@srebhan
Copy link
Copy Markdown
Member

srebhan commented Mar 18, 2026

Closing this in favor of #18568 which solves the panic at the roots. Anyway, thanks for jumping on this so quickly @hklhai!

@srebhan srebhan closed this Mar 18, 2026
@hklhai
Copy link
Copy Markdown
Author

hklhai commented Mar 20, 2026

Closing this in favor of #18568 which solves the panic at the roots. Anyway, thanks for jumping on this so quickly @hklhai!

😄 I didn’t really contribute much haha, but happy to see this resolved!

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.

Panic in outputs.heartbeat plugin since v1.38.0

2 participants