This repository was archived by the owner on Jun 29, 2026. It is now read-only.
Repository navigation
Conversation
… mismatch Replace broad 'except TypeError' catches in live.py and live_music.py with selective checks that only catch TypeErrors related to the 'decode' kwarg introduced in websockets 14.0+. This prevents masking unrelated TypeErrors from caller code (e.g., extra_headers vs additional_headers API changes in newer websockets), making debugging easier and restoring proper error propagation for other failure modes.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixed the bug described in issue googleapis#794. Here is what was wrong and how I fixed it:
The Problem:
The except TypeError block in live.py and live_music.py was catching ALL TypeErrors, including unrelated ones from caller code. When a newer websockets library version is used, TypeErrors can come from the caller's API (e.g., extra_headers vs additional_headers mismatch), but the broad catch made these look like version-compatibility issues. This masked real errors, made debugging harder, and caused the fallback path to trigger when it should not.
The Fix:
Changed the broad except TypeError: to a conditional check that only catches TypeErrors specifically related to the decode= keyword argument introduced in websockets 14.0+. The pattern:
except TypeError as e:
if decode in str(e):
# Fall back to older websockets API
else:
raise # Re-raise unrelated TypeErrors
This was applied in three places:
Testing by: Verified Python syntax on both modified files. The fix preserves backward compatibility with older websockets while properly surfacing unrelated TypeErrors from caller code.
Closes: googleapis#794