managed-chatkit: normalize upstream error payloads to readable strings - #130
Open
shuofengzhang wants to merge 1 commit into
Open
managed-chatkit: normalize upstream error payloads to readable strings#130shuofengzhang wants to merge 1 commit into
shuofengzhang wants to merge 1 commit into
Conversation
m74278803-cmyk
left a comment
There was a problem hiding this comment.
shuofengzhang:fix-managed-chatkit-error-message-shape
m74278803-cmyk
left a comment
There was a problem hiding this comment.
shuofengzhang:fix-managed-chatkit-error-message-shape
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.
What changed
resolve_error_message(...)inmanaged-chatkit/backend/app/main.pyto normalize upstream error payloads into a readable string./api/create-sessionerror handling to use this resolver instead of directly forwardingpayload["error"].managed-chatkit/backend/tests/test_main.pycovering:{"error": {"message": ...}}){"error": "..."})errorfield.Why
The OpenAI-style error shape is typically nested (for example,
{"error": {"message": "..."}}).Previously, the backend forwarded
payload["error"]directly, which could return an object instead of a string.That makes frontend/debug output inconsistent and can produce low-signal error displays (for example object rendering instead of a clear message).
Practical gain / Why this matters
/api/create-sessionnow consistently returns a human-readable string error.Insight / Why this matters
errorwas already a string.Testing
cd managed-chatkit/backend && source .venv/bin/activate && pytest -q3 passedcd managed-chatkit/backend && source .venv/bin/activate && python -m ruff check app testscd managed-chatkit/backend && source .venv/bin/activate && python -m ruff format --check app testscd managed-chatkit/backend && source .venv/bin/activate && python -m mypy app --ignore-missing-imports