fix: Pass snapshot_id as keyword argument to RemoveStatisticsUpdate#2694
Merged
Fokko merged 2 commits intoapache:mainfrom Nov 7, 2025
Merged
fix: Pass snapshot_id as keyword argument to RemoveStatisticsUpdate#2694Fokko merged 2 commits intoapache:mainfrom
Fokko merged 2 commits intoapache:mainfrom
Conversation
Fixes apache#2558 When removing snapshots with statistics, RemoveStatisticsUpdate was being instantiated with a positional argument, which violates Pydantic's BaseModel requirement that all fields be passed as keyword arguments. This caused a TypeError: BaseModel.__init__() takes 1 positional argument but 2 were given when calling table.maintenance.expire_snapshots(). Changed from: RemoveStatisticsUpdate(statistics_file.snapshot_id) To: RemoveStatisticsUpdate(snapshot_id=statistics_file.snapshot_id) All existing tests pass with this fix.
84bf13e to
58814d6
Compare
Fokko
approved these changes
Nov 7, 2025
Contributor
Fokko
left a comment
There was a problem hiding this comment.
Great catch @ForeverAngry 🙌
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.
Closes #2558
Rationale for this change
When removing snapshots with statistics,
RemoveStatisticsUpdatewas being instantiated with a positional argument, which, as suggested by @vndv, "violates Pydantic's BaseModel requirement that all fields be passed as keyword arguments". Shout out to @vndv for catching this 🚀This caused a
TypeError: BaseModel.__init__() takes 1 positional argument but 2 were givenwhen callingtable.maintenance.expire_snapshots().older_than(...).commit().Are these changes tested?
Yes, and a new test was added.
Existing tests only tested the
RemoveStatisticsUpdatedirectly, but didnt test the code path throughRemoveSnapshotsUpdatethat triggers the bug.Added
test_update_remove_snapshots_with_statisticstotest_expire_snapshots.pyto extend coverage for the condition.Are there any user-facing changes?
No.