fix(livekit): gracefully handle empty request body and strip whitespace#89
Merged
Conversation
…ces from interview_id
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Benji918
approved these changes
May 30, 2026
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.
Description
This PR implements critical robustness enhancements to the LiveKit endpoint controllers (
app/api/v1/routes/livekit.py). It ensures that the backend gracefully handles trailing/leading whitespaces in room path parameters (such astest-room%20) and processes empty request bodies (-d '') cleanly without raising unhandledjson.JSONDecodeErrorexceptions (preventing unexpected500 Internal Server Errors).Type of Change
feat— New featurefix— Bug fixrefactor— Code refactoring (no functional change)docs— Documentation updatetest— Adding or updating testschore— Maintenance (dependencies, CI, tooling)Related Issue
Closes # (LiveKit controller route robustness follow-up)
Changes Made
_parse_uuid& routes): Added automatic string trimming tointerview_idin path parameters. This prevents spaces in URL parameters from triggering uuid formatting validation exceptions or matching failures.request.json()Decoding (generate_token&post_result): Wrapped raw JSON body parsing in a try-except block falling back to{}on exceptions. This prevents empty request payloads (-d '') from raising unhandled backend exceptions.uv run ruff check- All checks passed!).Proof of Work
API Response / Screenshots
POST /api/v1/livekit/test-room%20/token (With empty body
-d '')Status:
200 OK{ "serverUrl": "wss://meetmind-5fv6f5wu.livekit.cloud", "roomName": "test-room", "participantName": "Test User", "participantToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiVGV..." }Test Cases
test_token_returns_correct_shape— Verifies token shape and LiveKit VideoGrants generation.test_token_test_room_bypass_works— Verifies test room bypass and manual participant naming.test_token_returns_404_for_unknown_interview— Verifies correct 404 response on unknown UUIDs.Test output
uv run pytest tests/test_livekit.py ======================= 19 passed, 2 warnings in 15.90s =======================Checklist
<type>/<short-description>)uv run pytest)