fix(stt): filter None values in config.save() to fix silent TOML serialization failure#5
Open
Kyotani-Hub wants to merge 1 commit into
Conversation
…zation error The `input_device` field defaults to `None`, but TOML has no null type. `tomli_w.dump()` raises `TypeError` on `None` values, which was caught by a bare `except Exception: return False`, making `save()` silently fail for all users with default settings. Fixes elevenlabs#3
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.
Summary
Config.save()silently fails (returnsFalse) for every user with default settings because theinput_devicefield defaults toNone, and TOML has no null type.When
tomli_w.dump()encountersNonein the data dict, it raises aTypeError. This exception is swallowed by the bareexcept Exception: return Falseblock, so the failure is completely silent — no config file is ever written after a fresh install.Root Cause
In
stt/src/elevenlabs_stt/config.py, thesave()method constructs the TOML data dict with all fields unconditionally:tomli_wfaithfully follows the TOML spec, which has no null/None type, sodump()raisesTypeError.Fix
Filter out
Nonevalues before passing the dict totomli_w.dump():When
input_deviceis explicitly set to a device name (a string), it is included normally. When it isNone(the default), it is simply omitted from the TOML file — andload()already handles missing keys correctly by using the Pydantic field defaults.Test plan
Config().save()returnsTrueand writes a validconfig.tomlinput_deviceset to a string: field appears in saved TOMLinput_deviceasNone(default): field is omitted,load()still returnsinput_device=Nonesave()thenload()preserves all non-None settingsFixes #3