|
9 | 9 | from sqlalchemy.exc import InvalidRequestError, OperationalError |
10 | 10 |
|
11 | 11 | from dbos import DBOS, Queue, SetWorkflowID |
| 12 | +from dbos._client import DBOSClient |
12 | 13 | from dbos._dbos_config import DBOSConfig |
13 | 14 | from dbos._error import ( |
14 | 15 | DBOSAwaitedWorkflowCancelledError, |
@@ -502,6 +503,36 @@ def test_error_serialization() -> None: |
502 | 503 | assert isinstance(exception, str) |
503 | 504 |
|
504 | 505 |
|
| 506 | +def test_workflow_error_serialization(dbos: DBOS, client: DBOSClient) -> None: |
| 507 | + |
| 508 | + @DBOS.step() |
| 509 | + def step() -> None: |
| 510 | + raise BadException(1, 2) |
| 511 | + |
| 512 | + @DBOS.workflow() |
| 513 | + def workflow() -> None: |
| 514 | + step() |
| 515 | + |
| 516 | + handle = DBOS.start_workflow(workflow) |
| 517 | + |
| 518 | + with pytest.raises(BadException): |
| 519 | + handle.get_result() |
| 520 | + |
| 521 | + workflows = DBOS.list_workflows() |
| 522 | + assert len(workflows) == 1 |
| 523 | + assert workflows[0].error is not None |
| 524 | + |
| 525 | + steps = DBOS.list_workflow_steps(handle.workflow_id) |
| 526 | + assert len(steps) == 1 |
| 527 | + assert steps[0]["error"] is not None |
| 528 | + |
| 529 | + status = handle.get_status() |
| 530 | + assert status.error is not None |
| 531 | + |
| 532 | + status = client.retrieve_workflow(handle.workflow_id).get_status() |
| 533 | + assert status.error is not None |
| 534 | + |
| 535 | + |
505 | 536 | def test_unregistered_workflow(dbos: DBOS, config: DBOSConfig) -> None: |
506 | 537 |
|
507 | 538 | @DBOS.workflow() |
|
0 commit comments