Skip to content

Commit 7184725

Browse files
committed
fix: fail closed on malformed source-snapshot-id in incremental cleanup
Java's IncrementalFileCleanup propagates the NumberFormatException when source-snapshot-id can't be parsed, so cherry-pick protection cannot be silently bypassed. Mirror that behavior by returning InvalidArgument from both parse sites instead of skipping the entry. Addresses wgtmac review feedback on PR #648.
1 parent 51d2e12 commit 7184725

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/iceberg/update/expire_snapshots.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "iceberg/file_io.h"
3232
#include "iceberg/manifest/manifest_entry.h"
3333
#include "iceberg/manifest/manifest_reader.h"
34+
#include "iceberg/result.h"
3435
#include "iceberg/schema.h"
3536
#include "iceberg/snapshot.h"
3637
#include "iceberg/statistics_file.h"
@@ -402,7 +403,11 @@ class IncrementalFileCleanup : public FileCleanupStrategy {
402403
try {
403404
picked_ancestor_snapshot_ids.insert(std::stoll(it->second));
404405
} catch (...) {
405-
// Malformed source-snapshot-id; skip rather than fail cleanup.
406+
return InvalidArgument(
407+
"Malformed {} '{}' on snapshot {}; cannot evaluate cherry-pick "
408+
"protection during incremental cleanup",
409+
SnapshotSummaryFields::kSourceSnapshotId, it->second,
410+
ancestor->snapshot_id);
406411
}
407412
}
408413

@@ -456,7 +461,11 @@ class IncrementalFileCleanup : public FileCleanupStrategy {
456461
try {
457462
source_snapshot_id = std::stoll(src_it->second);
458463
} catch (...) {
459-
source_snapshot_id = -1;
464+
return InvalidArgument(
465+
"Malformed {} '{}' on snapshot {}; cannot evaluate cherry-pick "
466+
"protection during incremental cleanup",
467+
SnapshotSummaryFields::kSourceSnapshotId, src_it->second,
468+
snapshot_id);
460469
}
461470
}
462471
// If this commit was cherry-picked from a still-live snapshot, skip --

0 commit comments

Comments
 (0)