Skip to content

fix(backup): report an unset completed_at as None - #2217

Open
RaphaelFakhri wants to merge 1 commit into
weaviate:mainfrom
RaphaelFakhri:fix/zero-completed-at
Open

RaphaelFakhri wants to merge 1 commit into
weaviate:mainfrom
RaphaelFakhri:fix/zero-completed-at

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

What this changes

Weaviate serializes the completedAt timestamp of a backup or export that has not finished yet as Go's zero time, 0001-01-01T00:00:00.000Z. The client parsed that value as-is, so for a running backup or export:

  • client.backup.list_backups(...) returned completed_at=datetime(1, 1, 1, tzinfo=UTC).
  • client.export.get_status(...) returned completed_at=datetime(1, 1, 1, tzinfo=UTC).

Both fields are typed Optional[datetime] with a None default, so code that checks completed_at is None to detect an unfinished operation, or that computes a duration from it, gets a wrong answer.

This change adds a field validator to BackupListReturn.completed_at and ExportStatusReturn.completed_at that maps the zero time to None. Real timestamps pass through unchanged.

Fixes #2216

Reproduction

Against Weaviate 1.40.0 with backup-filesystem and EXPORT_ENABLED=true:

c.backup.create(backup_id="bk2", backend=BackupStorage.FILESYSTEM)
print(c.backup.list_backups(backend=BackupStorage.FILESYSTEM)[0].completed_at)
# before: 0001-01-01 00:00:00+00:00
# after:  None

The raw response from GET /v1/backups/filesystem while the backup runs:

[{"classes":["Article"],"completedAt":"0001-01-01T00:00:00.000Z","id":"bk1","startedAt":"2026-10-21T06:49:36.565Z","status":"STARTED"}]

Tests

  • test/test_backup.py: an unset completedAt maps to None; a set one is kept.
  • test/test_export.py (new): the same two cases for ExportStatusReturn.

pytest test/test_backup.py test/test_export.py: 2 of the new tests fail without the fix and all 7 pass with it. pytest test passes (546 passed, 1 skipped). ruff format, ruff check, and flake8 are clean on the changed files.

Weaviate serializes the completedAt of a backup or export that is still
running as Go's zero time, 0001-01-01T00:00:00.000Z. list_backups() and
export.get_status() returned it as datetime(1, 1, 1) instead of None.

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@weaviate-git-bot

Copy link
Copy Markdown

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

This branch has not been deployed

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

Running backups and exports report completed_at as year 1 instead of None

2 participants