Skip to content

Conversation

@ForeverAngry
Copy link
Contributor

Closes #2558

Rationale for this change

When removing snapshots with statistics, RemoveStatisticsUpdate was 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 given when calling table.maintenance.expire_snapshots().older_than(...).commit().

Are these changes tested?

Yes, and a new test was added.

Existing tests only tested the RemoveStatisticsUpdate directly, but didnt test the code path through RemoveSnapshotsUpdate that triggers the bug.

Added test_update_remove_snapshots_with_statistics to test_expire_snapshots.py to extend coverage for the condition.

Are there any user-facing changes?

No.

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.
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.

TypeError in snapshot expiration due to positional argument to BaseModel in table/update/__init__.py

1 participant