Skip to content

fix(historical): return error instead of panic on unknown timezone#466

Merged
wboayue merged 1 commit intov2-stablefrom
fix/parse-time-zone-panic-v2
Apr 25, 2026
Merged

fix(historical): return error instead of panic on unknown timezone#466
wboayue merged 1 commit intov2-stablefrom
fix/parse-time-zone-panic-v2

Conversation

@wboayue
Copy link
Copy Markdown
Owner

@wboayue wboayue commented Apr 25, 2026

Summary

parse_time_zone in src/market_data/historical/common/decoders.rs panics when find_timezone returns no match. Both call sites already return Result<_, Error>, so propagate the failure as Error::Simple with the same registration-pointer text used by the connection-handshake error.

Why

After #464 added register_timezone_alias and IBAPI_TIMEZONE_ALIASES, users can extend the alias table at runtime. But parse_time_zone would still crash the whole process on an unmapped name in a historical schedule or bar response, defeating the registry escape hatch for the historical-data path. Now the failure is recoverable — surface it to the user with the same fix pointers.

Test plan

  • cargo +1.93.0 fmt
  • cargo +1.93.0 clippy --all-targets -- -D warnings
  • cargo +1.93.0 clippy --all-targets --features sync -- -D warnings
  • cargo +1.93.0 clippy --all-features
  • cargo +1.93.0 test --features sync (historical: 83 passed)
  • cargo +1.93.0 test --features async (historical: 53 passed)
  • New unit test test_decode_historical_schedule_unknown_timezone_errors exercises the error path and asserts the rendered message contains register_timezone_alias and IBAPI_TIMEZONE_ALIASES.

Companion PR

Main-branch port to follow.

`parse_time_zone` panicked when IB Gateway sent an unmapped timezone
name. Both call sites already return `Result<_, Error>`, so propagate
the failure with the same registration-pointer message used elsewhere.
@wboayue wboayue merged commit 12ddd93 into v2-stable Apr 25, 2026
3 checks passed
@wboayue wboayue deleted the fix/parse-time-zone-panic-v2 branch April 25, 2026 20:21
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