fix: harden workflow archive DB retries#38170
Open
zhaohao1004 wants to merge 2 commits into
Open
Conversation
d42741a to
510408e
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-06-29 12:31:34.117644145 +0000
+++ /tmp/pyrefly_pr.txt 2026-06-29 12:31:19.039572357 +0000
@@ -559,9 +559,9 @@
ERROR `unpatch` may be uninitialized [unbound-name]
--> tests/integration_tests/plugin/__mock/http.py:67:9
ERROR Argument `FakeArchiveStorage` is not assignable to parameter `storage` with type `ArchiveStorage | None` in function `services.retention.workflow_run.archive_paid_plan_workflow_run.WorkflowRunArchiver._archive_bundle` [bad-argument-type]
- --> tests/integration_tests/services/retention/test_workflow_run_archiver.py:412:56
+ --> tests/integration_tests/services/retention/test_workflow_run_archiver.py:530:56
ERROR Argument `FakeArchiveStorage` is not assignable to parameter `storage` with type `ArchiveStorage | None` in function `services.retention.workflow_run.archive_paid_plan_workflow_run.WorkflowRunArchiver._archive_bundle` [bad-argument-type]
- --> tests/integration_tests/services/retention/test_workflow_run_archiver.py:437:60
+ --> tests/integration_tests/services/retention/test_workflow_run_archiver.py:555:60
ERROR Argument `_stub_resolver._Resolver` is not assignable to parameter `binding_resolver` with type `WorkflowAgentBindingResolver | None` in function `services.workflow.node_output_inspector_service.NodeOutputInspectorService.__init__` [bad-argument-type]
--> tests/integration_tests/services/test_node_output_inspector_service.py:231:59
ERROR Argument `_stub_resolver._Resolver` is not assignable to parameter `binding_resolver` with type `WorkflowAgentBindingResolver | None` in function `services.workflow.node_output_inspector_service.NodeOutputInspectorService.__init__` [bad-argument-type]
@@ -1925,6 +1925,8 @@
ERROR `None` is not subscriptable [unsupported-operation]
--> tests/unit_tests/clients/agent_backend/test_event_adapter.py:53:12
ERROR Expected a callable, got `None` [not-callable]
+ --> tests/unit_tests/commands/test_archive_workflow_runs.py:124:9
+ERROR Expected a callable, got `None` [not-callable]
--> tests/unit_tests/commands/test_clean_expired_messages.py:33:9
ERROR Expected a callable, got `None` [not-callable]
--> tests/unit_tests/commands/test_clean_expired_messages.py:63:9
|
Contributor
Pyrefly Type Coverage
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #38170 +/- ##
========================================
Coverage 85.34% 85.35%
========================================
Files 4967 4968 +1
Lines 258448 258554 +106
Branches 49042 49050 +8
========================================
+ Hits 220580 220679 +99
+ Misses 33575 33561 -14
- Partials 4293 4314 +21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
This PR hardens the workflow run archive command against transient DB disconnects during archive planning and bundle processing.
What changed
ClickException, so Kubernetes CronJobs do not mark failed planning as success.Root cause
The archive command could still fail on stale DB connections in planning paths, while some planning failures were printed and returned from the Click command, causing a successful process exit. The retry classification also matched generic network-looking messages without first verifying that the exception was DB-related.
Validation
uv run --project api --group dev ruff check api/commands/retention.py api/services/retention/workflow_run/archive_paid_plan_workflow_run.py api/services/retention/workflow_run/db_retry.py api/tests/integration_tests/services/retention/test_workflow_run_archiver.py api/tests/unit_tests/commands/test_archive_workflow_runs.pyuv run --project api --group dev pytest api/tests/integration_tests/services/retention/test_workflow_run_archiver.py api/tests/unit_tests/commands/test_archive_workflow_runs.pyuv run --project api python -m py_compile api/commands/retention.py api/services/retention/workflow_run/archive_paid_plan_workflow_run.py api/services/retention/workflow_run/db_retry.py api/tests/integration_tests/services/retention/test_workflow_run_archiver.py api/tests/unit_tests/commands/test_archive_workflow_runs.py