Skip to content

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

Merged
wboayue merged 1 commit intomainfrom
fix/parse-time-zone-panic-main
Apr 25, 2026
Merged

fix(historical): return error instead of panic on unknown timezone#467
wboayue merged 1 commit intomainfrom
fix/parse-time-zone-panic-main

Conversation

@wboayue
Copy link
Copy Markdown
Owner

@wboayue wboayue commented Apr 25, 2026

Summary

parse_time_zone in src/market_data/historical/common/decoders/mod.rs panicked when find_timezone returned no match. Both call sites already return Result<_, Error>, so propagate the failure as the typed Error::UnsupportedTimeZone(name.to_string()). Its display already carries the register_timezone_alias / IBAPI_TIMEZONE_ALIASES registration hint added in #465.

Why

After #465 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 with the same fix pointers.

Test plan

  • cargo +1.95.0 fmt
  • cargo +1.95.0 clippy --all-targets -- -D warnings
  • cargo +1.95.0 clippy --all-targets --features sync -- -D warnings
  • cargo +1.95.0 clippy --all-features
  • cargo +1.95.0 test --features sync (historical: 92 passed)
  • cargo +1.95.0 test --features async (historical: 62 passed)
  • New unit test test_decode_historical_schedule_unknown_timezone_errors exercises the error path, asserts the typed variant via matches!, and asserts the rendered message contains register_timezone_alias and IBAPI_TIMEZONE_ALIASES.

Companion PR

v2-stable port: #466.

`parse_time_zone` panicked when IB Gateway sent an unmapped timezone
name. Both call sites already return `Result<_, Error>`, so propagate
the failure as `Error::UnsupportedTimeZone`, which already carries the
`register_timezone_alias` / `IBAPI_TIMEZONE_ALIASES` registration hint.
@wboayue wboayue merged commit 0ce0ba0 into main Apr 25, 2026
3 checks passed
@wboayue wboayue deleted the fix/parse-time-zone-panic-main 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