Skip to content

Reject malformed transcription temperature instead of reinterpreting it - #4553

Open
Daksha1611 wants to merge 1 commit into
openvinotoolkit:mainfrom
Daksha1611:fix-transcription-temperature
Open

Reject malformed transcription temperature instead of reinterpreting it#4553
Daksha1611 wants to merge 1 commit into
openvinotoolkit:mainfrom
Daksha1611:fix-transcription-temperature

Conversation

@Daksha1611

@Daksha1611 Daksha1611 commented Sep 11, 2026

Copy link
Copy Markdown

🛠 Summary

Fixes #4552.

parseTemperature() parsed the multipart temperature field with ovms::stof and, on failure, retried with ovms::stou32. ovms::stof requires the whole field to be consumed; ovms::stou32 does not, and it erases spaces first. The fallback therefore rescued exactly the values stof had just rejected, turning malformed input into a plausible temperature instead of the intended Invalid temperature type. error:

temperature=0.5x   -> accepted as 0.0, not 0.5, so sampling is silently off
temperature=0abc   -> accepted as 0.0
temperature=1e400  -> accepted as 1.0
temperature=5 5    -> accepted as 55.0

The fallback had no purpose — ovms::stof already parses integer spellings, so "1" never reached it. Every input it could rescue is malformed by definition. Removing it lets the existing error path fire.

This deliberately adds no range check. Passing a negative temperature through for GenAI to reject is the behaviour established by #4201 and pinned by negativeTemperatureEnableSampling, so I left it alone rather than quietly reverse it. Happy to revisit separately if the endpoint should enforce the OpenAI audio range at the parse layer.

Adds four cases for the spellings above. The three existing SttServableParseTemperatureTest cases are unaffected — -1.0, 0 and 1.0 all parse cleanly through ovms::stof and never reached the fallback.

The root cause is that ovms::stou32 alone among the stringutils converters does not check for a partial parse; that is #4554, and the two fixes are independent.

I have no OVMS build container available, so this is not compiled against the full tree and CI will need to confirm the build. I did check the change in isolation and verified the three existing test inputs behave identically. Draft for that reason.

🧪 Checklist

  • Unit tests added.
  • The documentation updated.
  • Change follows security best practices.

parseTemperature() parsed the multipart temperature field with ovms::stof
and, when that failed, retried with ovms::stou32. ovms::stof requires the
whole field to be consumed; ovms::stou32 does not. The fallback therefore
rescued precisely the values stof had just rejected, converting malformed
input into a plausible temperature rather than returning the intended
"Invalid temperature type." error:

  temperature=0.5x   -> accepted as 0.0   (not 0.5)
  temperature=0abc   -> accepted as 0.0
  temperature=1e400  -> accepted as 1.0   (stof throws out_of_range,
                                           stou32 parses the leading 1)
  temperature=5 5    -> accepted as 55.0  (stou32 erases spaces first)

The fallback had no legitimate purpose: ovms::stof already parses integer
spellings, so "1" was never reaching it. Drop it and let the existing error
path fire.

This deliberately does not add a range check. Passing a negative temperature
through for GenAI to reject is the behaviour established by openvinotoolkit#4201 ("Negative
temperature should lead to genai error in STT path") and pinned by
negativeTemperatureEnableSampling, so it is left alone.

Tests: adds four cases covering the malformed spellings above. The three
existing SttServableParseTemperatureTest cases (-1.0, 0, 1.0) are unaffected -
all three parse cleanly through ovms::stof and never reached the fallback.
@Daksha1611
Daksha1611 marked this pull request as ready for review September 12, 2026 07:09
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.

Transcription temperature: malformed values are silently reinterpreted instead of rejected

1 participant