Skip to content

Fix deprecation warnings from the frame serializer - #31

Merged
markbackman merged 3 commits into
mainfrom
mb/serializer-deprecation-warnings
Aug 19, 2026
Merged

Fix deprecation warnings from the frame serializer#31
markbackman merged 3 commits into
mainfrom
mb/serializer-deprecation-warnings

Conversation

@markbackman

@markbackman markbackman commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Every frame observed by Whisker emitted a burst of DeprecationWarnings — a dozen per StartFrame, repeated at each processor hop, unbounded and unsuppressable.

Two causes combined:

  • Pipecat's StartFrame intercepts reads of its migrated configuration fields (audio_in_sample_rate and six siblings) and warns on each read.
  • whisker_obj_serializer walks every dataclass field of every frame, and read each field twice — once to test it for None, once for its value.

The serializer now builds the field map in one pass, from raw instance state:

values = {f.name: object.__getattribute__(obj, f.name) for f in fields(obj)}
return {k: whisker_obj_serializer(v) for k, v in values.items() if v is not None}

object.__getattribute__ returns the same value while bypassing the interception, so serialized payloads are unchanged. A debug tool rendering a field shouldn't trip a notice aimed at callers using it.

Suppressing the warnings instead does not work: Pipecat raises them inside its own catch_warnings() + simplefilter("always"), which replaces the caller's filters for the duration of the call — a simplefilter("ignore") around serialization has no effect. The read has to be avoided, not silenced.

Also here:

  • Guarded the dataclass branch with not isinstance(obj, type). is_dataclass() is true for dataclass classes as well as instances, and object.__getattribute__ doesn't behave like getattr on a class. Such a value now serializes as <type: type> rather than its class-level defaults; no frame field is known to hold one.
  • Unrelated: added .env* to ui/.gitignore.

Related Pipecat change

This clears the warnings for anyone running both packages. A companion Pipecat change makes the deprecation warn once per call site instead of on every read, which bounds the same flood for users on older Whisker versions and for any other caller that reflects over frame fields. Not required by this PR.

Test plan

Whisker has no test suite, so whisker_obj_serializer was exercised directly:

  • 50 StartFrames serialized against a Pipecat build carrying the deprecation shim: 0 warnings, against 600 before the change.
  • StartFrame and TextFrame payloads compared before and after: identical.
  • uv run ruff check src/ and uv run ruff format --check src/ clean.

🤖 Generated with Claude Code

The serializer read each field twice, once to test it for `None` and once
for its value. Fields that intercept reads to warn about deprecation --
`StartFrame.audio_in_sample_rate` and its siblings -- emitted warnings on
every frame walked. Read the raw instance state via
`object.__getattribute__` instead, and skip dataclass types so only
instances are serialized.
markbackman added a commit that referenced this pull request Aug 19, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@markbackman
markbackman force-pushed the mb/serializer-deprecation-warnings branch from d59b091 to adbb160 Compare August 19, 2026 15:16
@markbackman
markbackman requested a review from aconchillo August 19, 2026 15:17
@aconchillo

Copy link
Copy Markdown
Contributor

LGTM!

@markbackman
markbackman merged commit f9df2ca into main Aug 19, 2026
3 checks passed
@markbackman
markbackman deleted the mb/serializer-deprecation-warnings branch August 19, 2026 15:48
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