xgbtxy opened a new pull request, #3774:
URL: https://github.com/apache/iceberg-rust/pull/3774

   ## Which issue does this PR close?
   
   - None (standalone bug fix discovered during snapshot expiration audit).
   
   ## What changes are included in this PR?
   
   Fix two edge-case bugs in `ExpireSnapshotsAction`:
   
   - Add a visited-set cycle guard to `ExpireSnapshotsAction::ancestors` 
(matching `crate::util::snapshot::ancestors_of`) so corrupt table metadata 
containing a `parent_snapshot_id` cycle terminates instead of hanging snapshot 
expiration in an infinite loop.
   - Validate per-branch `min_snapshots_to_keep` before converting from `i32` 
to `usize`, returning `ErrorKind::DataInvalid` for values `<= 0` instead of 
wrapping negative values to `usize::MAX` (which silently retained every 
snapshot on that branch) or accepting `0`.
   
   ## Are these changes tested?
   
   Yes. Added unit tests in 
`crates/iceberg/src/transaction/expire_snapshots.rs` covering non-positive 
per-branch `min_snapshots_to_keep` (`-1` and `0`) and cyclic snapshot parent 
chains (both two-snapshot cycles and self-parent cycles), and ran the 
`transaction::expire_snapshots` test suite (`cargo test -p iceberg --lib 
transaction::expire_snapshots`).
   
   ## AI Disclosure
   
   AI-assisted tooling was used to audit 
`crates/iceberg/src/transaction/expire_snapshots.rs`, draft the fix and unit 
tests, and run local verification.
   
   Areas of uncertainty / assumptions:
   - Assumes per-branch `min_snapshots_to_keep <= 0` should fail with 
`ErrorKind::DataInvalid` during `ExpireSnapshotsAction::commit`, matching the 
Iceberg spec ("A positive number for the minimum number of snapshots to keep") 
and the existing `retain_last(0)` validation.
   - Local verification ran on Windows with `cargo +stable` tests/clippy and 
`cargo +nightly fmt -- --check`; full workspace Linux CI and `public-api` 
checks will run on GitHub Actions.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to