fix(report): revert() by position so duplicate indexes are safe - #442
Merged
Merged
Conversation
…e safe CleanReport.revert() restored values via series.loc[labels] = value using the undo log's recorded index labels. On a non-unique index that assignment hit every row sharing a label, silently fabricating data (a repaired value written into rows that were originally null). _capture_undo now also records positional offsets and revert restores by position; reports without positions still revert by label. Found by the production-readiness fuzz campaign (FDC-L3-025).
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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 |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
…index # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CleanReport.revert()restored values viaseries.loc[labels] = valueusing the undo log's recorded index labels. On a non-unique index, that assignment writes the value into every row sharing a label — silently fabricating data: a repaired value lands in rows that were originally null (['café', None, None]reverted to['café', 'café', 'café']).Change
_capture_undo(repairplan.py) now also records positional offsets, andrevert()restores by position (series.iloc[positions]). Reports serialized by older versions (nopositions) still revert best-effort by label.Tests
tests/test_report.py::test_revert_restores_only_original_rows_on_duplicate_index(from the campaign repro): a duplicate-index frame reverts exactly to its input. 114 revert/plan/report tests pass on py3.12 and py3.9; ruff clean.Closes #. Found by the production-readiness fuzz campaign (FDC-L3-025).