fix(ooxml): move-sheet silent data corruption#213
Conversation
…odification tracking (#207) Workbook.reorder() set reorderedSheets=true but the surgical writer only checked modifiedMetadata to decide whether to regenerate all sheets. Unmodified sheets were copied from the source ZIP in original positions while workbook.xml referenced them in the new order — name/data mismatch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Code Review - PR #213: fix(ooxml): move-sheet silent data corruptionSummaryVerdict: ✅ LGTM - Excellent P0 bug fix This PR correctly addresses a critical data corruption bug where sheet reordering caused sheet names to point to wrong data. The fix is minimal, surgical, and precisely targets the root cause. What This PR Does Right1. Precise Root Cause Analysis ⭐The issue description correctly identifies that 2. Minimal, Surgical Fix ✅The fix touches exactly 2 locations in
Both locations add the same logical condition: 3. Comprehensive Regression Test ⭐The test in
This test will catch any future regressions of this specific issue. 4. Correct Understanding of Architecture ✅The PR author correctly understands that:
Code Quality AssessmentAdherence to CLAUDE.md Principles
Style & Conventions
Potential Considerations (Minor)1. Performance Impact (Low Priority)When However: This is the correct conservative behavior for a P0 data corruption fix. Premature optimization here would risk reintroducing the bug. If performance becomes an issue, a future enhancement could track per-sheet reordering mappings, but that's significantly more complex. 2. SharedStrings and Styles Regeneration (Question)Lines 1004-1009 regenerate Analysis: This is correct because:
No change needed here. 3. Test Coverage for Edge Cases (Nice-to-Have)The regression test covers the basic case (3 sheets, move one to front). Additional edge cases could be tested:
However: The current test is sufficient for the P0 fix. Additional tests can be added if issues arise. Security & Safety✅ No security concerns: Fix is purely internal logic, no user input handling changes Test Execution PlanThe PR description states:
Recommendation: Merge after CI passes. The fix is sound and well-tested. Final Assessment
Overall: 5/5 - Exemplary P0 bug fix. Merge immediately after CI. References
|
Summary
move-sheetcaused silent data corruption where sheet names pointed to wrong data after reorderWorkbook.reorder()setreorderedSheets=truebut the surgical writer only checkedmodifiedMetadatato decide whether to regenerate all sheetsworkbook.xmlreferenced them in the new orderTest plan
XlsxWriterCorruptionRegressionSpec— creates 3 sheets with distinct data, reorders, round-trips, verifies each sheet name maps to correct datamove-sheet "C" --to 0now preserves correct data mappingCloses #207
🤖 Generated with Claude Code