Skip to content

fix: supertrend Subscribe panics on disabled linearRegression config#2554

Open
rs-assistant wants to merge 1 commit into
c9s:mainfrom
andycheng123:fix/supertrend-linreg-subscribe-panic
Open

fix: supertrend Subscribe panics on disabled linearRegression config#2554
rs-assistant wants to merge 1 commit into
c9s:mainfrom
andycheng123:fix/supertrend-linreg-subscribe-panic

Conversation

@rs-assistant

Copy link
Copy Markdown
Contributor

What

setupIndicators() nils LinearRegression when window == 0 or the interval is empty, but Subscribe() dereferences s.LinearRegression.Interval unconditionally.

A config like:

exchangeStrategies:
- on: binance
  supertrend:
    symbol: BTCUSDT
    interval: 1h
    window: 50
    linearRegression:
      window: 0

panics with a nil-interval subscribe (and a block without an interval panics inside session.Subscribe on the empty kline interval).

Fix

Guard both panic paths in Subscribe(), consistent with the setupIndicators() disable semantics. Degenerate configs that set an interval with window: 0 keep their historical (unused) subscription, so existing backtest replay inputs are unchanged.

Tests

Added TestStrategySubscribe_LinearRegressionNilSafe covering nil block / window-zero block / valid block (separate interval) — the first two panicked before this fix.

🤖 Generated with Claude Code

https://claude.ai/code/session_018hiceFQWejhHyHnLayt1dE

setupIndicators() nils LinearRegression when window == 0 or the interval is
empty, but Subscribe() dereferenced s.LinearRegression.Interval
unconditionally: a config with

    linearRegression:
      window: 0

panics with a nil pointer (and an interval-less block panics inside
session.Subscribe on the empty kline interval). Guard both panic paths;
degenerate configs that set an interval with window == 0 keep their
historical (unused) subscription so existing backtest replay inputs are
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018hiceFQWejhHyHnLayt1dE
@c9s

c9s commented Jul 20, 2026

Copy link
Copy Markdown
Owner

build failed

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.

2 participants