Skip to content

fix(pydantic): propagate SDK internal exceptions - #233

Open
1fanwang wants to merge 1 commit into
restatedev:mainfrom
1fanwang:1fannnw/propagate-sdk-internal-exceptions
Open

1fanwang wants to merge 1 commit into
restatedev:mainfrom
1fanwang:1fannnw/propagate-sdk-internal-exceptions

Conversation

@1fanwang

Copy link
Copy Markdown

The pydantic model wrapper currently turns Restate SDK control-flow exceptions into a plain Exception. That makes suspension and retry control paths look like ordinary model-call failures, so callers have to inspect __cause__ to recover the real Restate exception.

This keeps SdkInternalBaseException and its subclasses unchanged when they leave the journaled pydantic model call. The same change applies to streaming model calls. I left provider 4xx classification out because the issue proposes a policy, but there is no maintainer-confirmed mapping yet.

Part of #225

Testing Done

Raw logs

Red, with the old wrapper implementation restored over the new regression test:

$ git checkout HEAD^ -- python/restate/ext/pydantic/_model.py
$ uv run -m pytest tests/ext_pydantic_model.py -q
...
E           Exception: Internal error during model call
python/restate/ext/pydantic/_model.py:85: Exception
...
E           Exception: Internal error during model stream call
python/restate/ext/pydantic/_model.py:125: Exception
=========================== short test summary info ============================
FAILED tests/ext_pydantic_model.py::test_request_propagates_sdk_internal_exception
FAILED tests/ext_pydantic_model.py::test_request_stream_propagates_sdk_internal_exception
2 failed in 0.83s

Green, after restoring this branch's wrapper implementation:

$ git checkout HEAD -- python/restate/ext/pydantic/_model.py
$ uv run -m pytest tests/ext_pydantic_model.py -q
..                                                                       [100%]
2 passed in 0.61s

Signed-off-by: 1fanwang <1fannnw@gmail.com>
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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.

1 participant