Skip to content

fix(report): revert() by position so duplicate indexes are safe - #442

Merged
kevincostner17 merged 2 commits into
mainfrom
fix/revert-duplicate-index
Sep 16, 2026
Merged

kevincostner17 merged 2 commits into
mainfrom
fix/revert-duplicate-index

Conversation

@kevincostner17

Copy link
Copy Markdown
Contributor

Summary

CleanReport.revert() restored values via series.loc[labels] = value using 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, and revert() restores by position (series.iloc[positions]). Reports serialized by older versions (no positions) 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).

…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).
@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 54c0793f-f92a-426f-bfb0-84958dce733f


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

FreshData benchmark report — performance

  • freshdata: ?
  • python: ?
  • platform: ?
fixture n_rows n_cols p50 s p95 s peak MB repair % false-repair % preserve % trust monotonic export %

Authored-code reduction (Metric 6)

@kevincostner17
kevincostner17 merged commit d6cf054 into main Sep 16, 2026
22 checks passed
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