Skip to content

Refactor TTS audio generation in tts_service.py and cms_plans_service…#779

Closed
tenkus47 wants to merge 2 commits into
developfrom
tts-error-handling
Closed

Refactor TTS audio generation in tts_service.py and cms_plans_service…#779
tenkus47 wants to merge 2 commits into
developfrom
tts-error-handling

Conversation

@tenkus47

Copy link
Copy Markdown
Member

….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.

….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.
@tenkus47 tenkus47 requested a review from Tech-lo June 18, 2026 17:12
@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Safe 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

Comment on lines +136 to +140
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
52.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Tech-lo Tech-lo closed this Jun 19, 2026
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.

2 participants