Copilot commented on code in PR #42654:
URL: https://github.com/apache/superset/pull/42654#discussion_r3692950937
##########
tests/integration_tests/dashboards/version_restore_tests.py:
##########
@@ -225,14 +227,16 @@ def test_restore_preserves_live_chart_content(self) ->
None:
db.session.commit()
ver_cls = version_class(Dashboard)
+ entity_uuid = dashboard.uuid
+ assert entity_uuid is not None
target_tx = (
db.session.query(ver_cls.transaction_id)
.filter(ver_cls.id == dashboard_id)
.order_by(ver_cls.transaction_id.desc())
.limit(1)
.scalar()
)
- target_uuid = str(derive_version_uuid(dashboard.uuid, target_tx))
+ target_uuid = str(derive_version_uuid(entity_uuid, target_tx))
Review Comment:
`target_tx` comes from `.scalar()` and can be `None` if no version rows are
found. Passing `None` into `derive_version_uuid` will compute a UUID for a
non-existent version and fail later in a less obvious way. Add an explicit
`assert target_tx is not None` before deriving to make failures clearer (and
keep the call contract tight).
This issue also appears on line 297 of the same file.
##########
tests/integration_tests/charts/version_restore_tests.py:
##########
@@ -421,14 +426,16 @@ def
test_restore_stamps_action_kind_restore_on_transaction(self) -> None:
db.session.commit()
ver_cls = version_class(Slice)
+ entity_uuid = chart.uuid
+ assert entity_uuid is not None
first_tx = (
db.session.query(ver_cls.transaction_id)
.filter(ver_cls.id == chart_id)
.order_by(ver_cls.transaction_id.asc())
.limit(1)
.scalar()
)
- target_uuid = str(derive_version_uuid(chart.uuid, first_tx))
+ target_uuid = str(derive_version_uuid(entity_uuid, first_tx))
Review Comment:
`first_tx` comes from `.scalar()` and can be `None` if no version rows are
found. Passing `None` into `derive_version_uuid` will compute a UUID for a
non-existent version and the test will fail later (e.g. on the restore
response) with a less direct signal. Add `assert first_tx is not None` before
deriving to make failures clearer and keep the helper contract strict.
--
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]