Skip to content

fix(voice): reject non-positive audio frame rates - #4383

Closed
hsusul wants to merge 1 commit into
openai:mainfrom
hsusul:fix/voice-validate-frame-rate
Closed

fix(voice): reject non-positive audio frame rates#4383
hsusul wants to merge 1 commit into
openai:mainfrom
hsusul:fix/voice-validate-frame-rate

Conversation

@hsusul

@hsusul hsusul commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

_buffer_to_audio_file in agents/voice/input.py validates the sample width, buffer dtype, channel count, and multichannel frame completeness, and raises UserError for each. It does not validate the frame rate. A frame_rate of 0 or a negative value passes straight to wave.setframerate, so the caller sees a low-level wave.Error ("sampling rate not specified") instead of the UserError the sibling validations raise. This adds an up-front frame_rate <= 0 check so a bad sample rate fails the same consistent, actionable way, completing the input validation added in #4361, #4370, and #4372.

Test plan

Added test_audio_input_rejects_non_positive_frame_rate in tests/voice/test_input.py, parametrized over 0 and -8000, mirroring the existing non-positive-channels test. It asserts AudioInput.to_audio_file() raises UserError matching "Frame rate must be greater than zero". The test fails on main (a wave.Error leaks) and passes with this change. The full tests/voice/test_input.py suite stays green.

uv run pytest tests/voice/test_input.py

Issue number

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

_buffer_to_audio_file validates sample width, dtype, channel count, and
frame completeness, but not the frame rate. A frame rate of 0 or a negative
value reached wave.setframerate and surfaced as a low-level wave.Error rather
than the UserError contract the other input validations raise. Reject a
non-positive frame rate up front so the failure is consistent and actionable.
@seratch

seratch commented Aug 13, 2026

Copy link
Copy Markdown
Member

Closing this PR for the reason I mentioned at #4382 (review)

@seratch seratch closed this Aug 13, 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