fix: raise ValueError on empty base_state in apply_sparse_delta#67
fix: raise ValueError on empty base_state in apply_sparse_delta#67Grizouforever wants to merge 1 commit into
Conversation
…ence When target_dtype is None and base_state is an empty dict, calling next(iter(base_state.values())) raises StopIteration which propagates uncaught to callers in checkpoint_consumer.py. Add an explicit check that raises a clear ValueError instead. Also add two regression tests covering the empty base_state path. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughA bug fix that adds validation to Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
apply_sparse_deltacrashes with unhandledStopIterationwhenbase_stateis empty andtarget_dtype=NoneValueError("Cannot infer target_dtype: base_state is empty")before thenext(iter(...))callValueError, (2) empty base_state with explicit dtype returns empty dictRoot Cause
In
grail/infrastructure/delta_checkpoint.pyline 137, dtype is inferred by callingnext(iter(base_state.values())). Whenbase_stateis an empty dict, this raisesStopIterationwhich propagates uncaught to callers incheckpoint_consumer.py(lines 439-444 and 1315-1319) that passtarget_dtype=None.Fix
Test plan
test_delta_checkpoint.pytests passtest_empty_base_state_raises_value_errorconfirmsValueErroris raisedtest_empty_base_state_with_explicit_dtypeconfirms empty base_state + explicit dtype returns{}🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes