Refactor TTS audio generation in tts_service.py and cms_plans_service…#779
Refactor TTS audio generation in tts_service.py and cms_plans_service…#779tenkus47 wants to merge 2 commits into
Conversation
….py. Extracted audio extraction logic into a separate function and added error handling in _generate_tts_wav. Updated tests to cover scenarios where candidate content is None.
Confidence Score: 5/5Safe to merge; the refactoring is narrowly scoped and the core logic change (guarding against a None candidate content) is correct and tested. All changes are either pure extractions of existing logic or straightforward guard additions. The one known semantic mismatch (HTTP 502 response body carrying a BAD_REQUEST error code) was flagged in a previous review thread. No new logic bugs were found. No files require special attention. Reviews (2): Last reviewed commit: "Update imports in plan_items_models.py a..." | Re-trigger Greptile |
| except RuntimeError as exc: | ||
| raise HTTPException( | ||
| status_code=status.HTTP_502_BAD_GATEWAY, | ||
| detail=ResponseError(error=BAD_REQUEST, message=str(exc)).model_dump(), | ||
| ) from exc |
There was a problem hiding this comment.
Misleading error code in 502 response body. The
error field is set to BAD_REQUEST ("Bad request") even though the HTTP status is 502 Bad Gateway, so a client that inspects the response body to determine error category would conclude the caller did something wrong rather than that an upstream service failed. The UNEXPECTED_ERROR_UPLOAD constant is available in response_message.py and would be a closer semantic match, or a new BAD_GATEWAY constant could be added. Compare the 400 branch above which uses BAD_REQUEST consistently with its status code.
| except RuntimeError as exc: | |
| raise HTTPException( | |
| status_code=status.HTTP_502_BAD_GATEWAY, | |
| detail=ResponseError(error=BAD_REQUEST, message=str(exc)).model_dump(), | |
| ) from exc | |
| except RuntimeError as exc: | |
| raise HTTPException( | |
| status_code=status.HTTP_502_BAD_GATEWAY, | |
| detail=ResponseError(error=UNEXPECTED_ERROR_UPLOAD, message=str(exc)).model_dump(), | |
| ) from exc |
…Notification. Removed notifications_router from __all__ exports.
|


….py. Extracted audio extraction logic into a separate function and added error handling in _generate_tts_wav. Updated tests to cover scenarios where candidate content is None.