Skip to content

[BUG] fix auto_format_on_load crash for RangeIndex time series (#413

Open
eyasir2047 wants to merge 1 commit intosktime:mainfrom
eyasir2047:fix/390-rangeindex-auto-format-crash
Open

[BUG] fix auto_format_on_load crash for RangeIndex time series (#413
eyasir2047 wants to merge 1 commit intosktime:mainfrom
eyasir2047:fix/390-rangeindex-auto-format-crash

Conversation

@eyasir2047
Copy link
Copy Markdown

Reference Issues/PRs

Fixes #390

What does this implement/fix? Explain your changes.

I ran into this while testing load_data_source with a simple dict-based dataset (no datetime column). The auto-format step was crashing internally with 'RangeIndex' object has no attribute 'freq' — even though the request returned success=True, the formatting silently failed behind the scenes.

The root cause is in format_data_handle(): it calls y.index.freq, pd.infer_freq() and pd.date_range() without checking whether the index is actually datetime-like. A plain integer/RangeIndex doesn't have a .freq attribute, so it blows up.

The fix is a simple guard at the start of the frequency inference block — if the index is a RangeIndex, we skip all the datetime logic and just label the frequency as "Integer". Nothing else changes for datetime-indexed data.

Does your contribution introduce a new dependency? If yes, which one?

No, just uses pd.RangeIndex which is already available.

What should a reviewer concentrate their feedback on?

Mostly the guard condition around line 790 in executor.py— want to make sure it covers all the non-datetime index cases cleanly.

Any other comments?

Added 3 tests covering the unit-level fix, metadata output, and the full end-to-end load_data_sourcecall. Full test suite passes, ruff and format checks are clean.

PR checklist

For all contributions

[x] I've added unit tests and made sure they pass locally.

…e#390)

The format_data_handle method assumed all indexes are datetime-like,
calling y.index.freq, pd.infer_freq(), and pd.date_range() unconditionally.
This crashed with 'RangeIndex object has no attribute freq' for valid
integer-indexed time series data.

Fix:
- Add guard to skip datetime-specific frequency inference for RangeIndex
  and non-datetime indexes, setting 'Integer' as the frequency label
- Guard the explicit freq assignment (step 5) against integer indexes
- Guard metadata frequency access against RangeIndex

Tests:
- test_format_data_handle_rangeindex_no_crash: direct unit test
- test_format_data_handle_rangeindex_metadata: verify 'Integer' label
- test_load_data_source_rangeindex_end_to_end: full pipeline test
@biru-codeastromer
Copy link
Copy Markdown
Contributor

@eyasir2047 You made a duplicate PR to a already linked PR. Please check the issue if there are any attached linked PR's

@eyasir2047
Copy link
Copy Markdown
Author

eyasir2047 commented May 5, 2026

@biru-codeastromer Thanks for letting me know! I'll take a look at the linked PR and close this one if it already covers the fix.

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.

[BUG] auto_format_on_load crashes internally for valid RangeIndex time series

2 participants