Skip to content

fix(commons): report TTS options allocation failures as out-of-memory - #1147

Open
ShryukGrandhi wants to merge 1 commit into
RunanywhereAI:mainfrom
ShryukGrandhi:fix/issue-1060-commons-tts-allocation-failures-surface
Open

ShryukGrandhi wants to merge 1 commit into
RunanywhereAI:mainfrom
ShryukGrandhi:fix/issue-1060-commons-tts-allocation-failures-surface

Conversation

@ShryukGrandhi

@ShryukGrandhi ShryukGrandhi commented Oct 20, 2026 •

Copy link
Copy Markdown

Description

rac_tts_options_from_proto can only fail when it cannot allocate a string, because every caller passes a non-null out. Its three call sites still reported that as RAC_ERROR_DECODING_ERROR ("failed to convert TTSOptions"), so a real out-of-memory condition looked like malformed client input:

  • rac_tts_synthesize_lifecycle_proto (tts_module.cpp)
  • rac_tts_synthesize_stream_lifecycle_proto (tts_module.cpp)
  • rac_tts_stream_start_proto (rac_tts_stream.cpp)

The adapter now returns a rac_result_t instead of a bool: RAC_ERROR_NULL_POINTER for a null out, RAC_ERROR_OUT_OF_MEMORY when the voice or language copy fails, and RAC_SUCCESS otherwise. The three call sites pass that code through. Only the return type changes. The cleanup and failure-output rules in the header comment stay as they were. Malformed request bytes are still rejected earlier, when the request is parsed, and still return RAC_ERROR_DECODING_ERROR. This matches how rac_vlm_image_from_proto already separates the two cases.

No other code calls the adapter (I checked core/, engines/ and bindings/).

Fixes #1060

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring

Testing

  • Lint passes locally (git clang-format --diff HEAD -- core reports no changes to the touched lines)
  • Added/updated tests for changes

I extended core/tests/test_nonllm_lifecycle_proto_abi.cpp. When rac_commons is a static library, the test defines its own rac_alloc / rac_free / rac_strdup, which keeps the linker from using rac_memory.cpp's versions. The test's rac_strdup returns NULL for one sentinel string. I put that sentinel into TTSOptions.language_code and, separately, into TTSOptions.voice, and checked that all three ABIs return RAC_ERROR_OUT_OF_MEMORY. Malformed request bytes still return RAC_ERROR_DECODING_ERROR on all three. The mock TTS backend gained a trivial synthesize_stream, so the lifecycle stream path gets as far as the options conversion. The interposition only builds when rac_commons is a STATIC_LIBRARY, which is set in core/tests/CMakeLists.txt.

Without the fix, the test reports 6 failures (all of the OOM checks). With it, all checks pass.

cmake --preset macos-debug
cmake --build build/macos-debug
ctest --preset macos-debug   # 100% tests passed out of 106

Labels

  • Commons - Changes to shared native code (core)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)

Summary by cubic

Reports out-of-memory conditions during TTS options conversion as RAC_ERROR_OUT_OF_MEMORY instead of RAC_ERROR_DECODING_ERROR, so allocation failures are no longer indistinguishable from malformed client input.

  • rac_tts_options_from_proto now returns rac_result_t; its three call sites (lifecycle one-shot, lifecycle stream, and stream sessions) propagate that result instead of always reporting a decoding error.
  • Malformed request bytes are still rejected during parsing and return RAC_ERROR_DECODING_ERROR.
  • Adds ABI tests that inject allocation failures via a test-local rac_strdup and verify all three call sites report RAC_ERROR_OUT_OF_MEMORY.

Fixes #1060.

Written for commit c2b016f. Summary will update on new commits.

View guided diff

Summary by CodeRabbit

  • Bug Fixes
    • TTS requests now report more specific errors when options cannot be processed, including insufficient memory and invalid output handling.
    • One-shot, streaming, and session-start synthesis consistently preserve and return the underlying option-conversion error instead of reporting a generic decoding failure.
    • Malformed TTS requests continue to return a decoding error.

rac_tts_options_from_proto now returns a rac_result_t instead of a bool, so
its three call sites (the lifecycle one-shot, lifecycle stream and stream
session ABIs) propagate RAC_ERROR_OUT_OF_MEMORY for a failed string copy
instead of reporting RAC_ERROR_DECODING_ERROR. Malformed request bytes still
fail in parsing with a decoding error.

Fixes RunanywhereAI#1060
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 585d7577-39f9-4956-8fd0-efbf6a9e304b
📥 Commits

Reviewing files that changed from the base of the PR and between 259521e and c2b016f.

📒 Files selected for processing: 6
  • core/include/rac/features/tts/rac_tts_proto_adapters.h
  • core/src/features/tts/rac_tts_stream.cpp
  • core/src/features/tts/tts_module.cpp
  • core/src/foundation/rac_proto_adapters.cpp
  • core/tests/CMakeLists.txt
  • core/tests/test_nonllm_lifecycle_proto_abi.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The TTS proto adapter now returns typed result codes for conversion outcomes. Unary, streaming, and session-start synthesis paths propagate allocation errors instead of reporting them as decoding errors.

Changes: TTS error propagation

Layer / File(s) Summary
Typed conversion results
core/include/rac/features/tts/rac_tts_proto_adapters.h, core/src/foundation/rac_proto_adapters.cpp
rac_tts_options_from_proto returns rac_result_t. It reports null output and string allocation failures with specific error codes.
Caller propagation and validation
core/src/features/tts/rac_tts_stream.cpp, core/src/features/tts/tts_module.cpp, core/tests/CMakeLists.txt, core/tests/test_nonllm_lifecycle_proto_abi.cpp
TTS synthesis paths return the adapter’s conversion error. Lifecycle ABI tests check allocation failures and malformed requests across one-shot, streaming, and session-start APIs.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: sanchitmonga22

Merge Risk: ⚪ Minimal · up to c2b01

No actionable merge-blocking risk is established; the change is ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: TTS allocation failures are reported as out-of-memory errors.
Description check Passed The description includes the change summary, bug-fix classification, testing details, affected label, checklist status, linked issue, and platform testing context. It is complete and aligned with the …
Linked Issues check Passed Issue #1060 requires allocation failures from rac_tts_options_from_proto to reach all three TTS call sites as RAC_ERROR_OUT_OF_MEMORY, while malformed requests remain RAC_ERROR_DECODING_ERROR. T…
Out of Scope Changes check Passed The changes stay within issue #1060. The header and adapter update the result contract. The three callers propagate the result. The CMake interposition and test-local allocation hooks support allocati…
Full details: Description check

Explanation

The description includes the change summary, bug-fix classification, testing details, affected label, checklist status, linked issue, and platform testing context. It is complete and aligned with the template.

Full details: Linked Issues check

Explanation

Issue #1060 requires allocation failures from rac_tts_options_from_proto to reach all three TTS call sites as RAC_ERROR_OUT_OF_MEMORY, while malformed requests remain RAC_ERROR_DECODING_ERROR. The adapter now returns rac_result_t and maps string-copy failures to RAC_ERROR_OUT_OF_MEMORY. rac_tts_synthesize_lifecycle_proto, rac_tts_synthesize_stream_lifecycle_proto, and rac_tts_stream_start_proto return that result. The added ABI tests cover voice and language allocation failures across all three APIs and cover malformed request bytes with RAC_ERROR_DECODING_ERROR.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #1060. The header and adapter update the result contract. The three callers propagate the result. The CMake interposition and test-local allocation hooks support allocation-failure tests. The mock streaming operation enables coverage of the stream lifecycle path. No unrelated behavior or files are changed.

Full details: Docstring Coverage

Explanation

Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 5 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="core/src/foundation/rac_proto_adapters.cpp">

<violation number="1" location="core/src/foundation/rac_proto_adapters.cpp:299">
P3: The shared adapter contract still says null inputs return `false`, but this adapter now returns `RAC_ERROR_NULL_POINTER`. Update the file-level comment to describe result-code returns for this adapter.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

rac_tts_options_t* out) {
if (!out)
return false;
return RAC_ERROR_NULL_POINTER;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: The shared adapter contract still says null inputs return false, but this adapter now returns RAC_ERROR_NULL_POINTER. Update the file-level comment to describe result-code returns for this adapter.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At core/src/foundation/rac_proto_adapters.cpp, line 299:

<comment>The shared adapter contract still says null inputs return `false`, but this adapter now returns `RAC_ERROR_NULL_POINTER`. Update the file-level comment to describe result-code returns for this adapter.</comment>

<file context>
@@ -293,19 +293,20 @@ bool rac_stt_result_to_proto(const rac_stt_result_t* in, ::runanywhere::v1::STTO
+                                        rac_tts_options_t* out) {
     if (!out)
-        return false;
+        return RAC_ERROR_NULL_POINTER;
     *out = RAC_TTS_OPTIONS_DEFAULT;
     out->language = nullptr;
</file context>

This branch has not been deployed

No deployments
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.

commons: TTS allocation failures surface as RAC_ERROR_DECODING_ERROR

1 participant