fix: add max size check on audio base64 input (closes #1944)
Summary
Add a maximum size guard on base64-encoded audio input before decoding to prevent OOM on excessively large payloads.
Changes
- Added
MAX_AUDIO_BASE64_LENconstant (33,554,432 bytes = 32 MiB of base64 text β 24 MiB decoded) - Added early-return guard before
BASE64.decode()incloud_transcribe.rs - Returns friendly error message when limit is exceeded
Checklist
- [x]
cargo checkpasses - [x]
cargo fmt --checkpasses
Summary by CodeRabbit
- Bug Fixes
- Cloud transcription now validates audio file size and rejects oversized requests with a clear error message, preventing upload issues.
This PR adds a size validation gate to the voice transcription pipeline. A new constant Audio payload size validation π― 1 (Trivial) | β±οΈ ~5 minutes π° A bunny guards the audio gate,
Measuring base64 before it's too late,
No oversized payloads shall pass through today,
Just gentle validation to keep chaos at bay! π€β¨ βοΈ Tip: You can configure your own custom pre-merge checks in the settings.π Walkthrough
Walkthrough
MAX_AUDIO_BASE64_LEN defines the maximum base64 input size, and the transcribe_cloud function now rejects requests with oversized payloads before attempting to decode or upload.Changes
Layer / File(s)
Summary
Audio payload size limit and validation
src/openhuman/voice/cloud_transcribe.rsMAX_AUDIO_BASE64_LEN constant defines the payload ceiling, and transcribe_cloud validates the trimmed audio_base64 length and rejects oversized inputs with a formatted error before any decode step.Estimated code review effort
Possibly related issues
Poem
π₯ Pre-merge checks | β
5
β
Passed checks (5 passed)
Check name
Status
Explanation
Description Check
β
Passed
Check skipped - CodeRabbitβs high-level summary is enabled.
Title check
β
Passed
The title clearly summarizes the main change: adding a maximum size check on audio base64 input, which matches the primary objective of the PR.
Docstring Coverage
β
Passed
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check
β
Passed
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
β
Passed
Check skipped because no linked issues were found for this pull request.
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 @coderabbitai help to get the list of available commands and usage tips.