Skip to content

Commit ae416f5

Browse files
committed
feat(backup): expose incremental_base_backup_id on BackupListReturn
GET /backups/{backend} returns incremental_base_backup_id per item (see BackupListResponseItems0 and Scheduler.List in weaviate/weaviate), but BackupListReturn does not declare the field, so list_backups() silently drops it and callers cannot tell which base backup an incremental backup was built on without a separate get_create_status() call per backup. Add the field as Optional[str] defaulting to None: the server omits it for non-incremental backups and only populates it for callers it has confirmed as root, so its absence must stay non-fatal.
1 parent ae327ca commit ae416f5

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

test/test_backup.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from typing import Any, Dict
2+
3+
import pytest
4+
5+
from weaviate.backup.backup import BackupListReturn, BackupStatus
6+
7+
8+
def _list_entry(**overrides: Any) -> Dict[str, Any]:
9+
"""A single item as Weaviate's ``GET /backups/{backend}`` returns it."""
10+
entry: Dict[str, Any] = {
11+
"id": "my-backup",
12+
"classes": ["Article"],
13+
"status": "SUCCESS",
14+
"startedAt": "2026-08-01T10:00:00.000Z",
15+
"completedAt": "2026-08-01T10:05:00.000Z",
16+
"size": 1.5,
17+
}
18+
entry.update(overrides)
19+
return entry
20+
21+
22+
def test_list_return_exposes_incremental_base_backup_id() -> None:
23+
backup = BackupListReturn(**_list_entry(incremental_base_backup_id="base-backup"))
24+
25+
assert backup.incremental_base_backup_id == "base-backup"
26+
assert backup.backup_id == "my-backup"
27+
assert backup.collections == ["Article"]
28+
assert backup.status == BackupStatus.SUCCESS
29+
30+
31+
@pytest.mark.parametrize(
32+
"entry",
33+
[
34+
pytest.param(_list_entry(), id="field_omitted"),
35+
pytest.param(_list_entry(incremental_base_backup_id=None), id="field_null"),
36+
],
37+
)
38+
def test_list_return_defaults_incremental_base_backup_id_to_none(entry: Dict[str, Any]) -> None:
39+
# The server omits the field for non-incremental backups, and only populates
40+
# it for callers it has confirmed as root, so absent must not be an error.
41+
assert BackupListReturn(**entry).incremental_base_backup_id is None

weaviate/backup/backup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,6 @@ class BackupListReturn(BaseModel):
104104
started_at: Optional[datetime] = Field(alias="startedAt", default=None)
105105
completed_at: Optional[datetime] = Field(alias="completedAt", default=None)
106106
size: float = Field(default=0)
107+
# None when the backup is not incremental, and also when the server omits the
108+
# field: it is only returned to callers Weaviate has confirmed as root.
109+
incremental_base_backup_id: Optional[str] = Field(default=None)

0 commit comments

Comments
 (0)