Fix generate_stream error in ClientV2 #725
Open
+24
−0
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.
Problem
Both the fern-generated Client and ClientV2 assign to self._raw_client. The .fernignore'd wrapper
ClientV2inherits from both, so its _raw_client parameter was getting set to the V2 only (since it is constructed last).Fix
Create a proxy raw client that will delegate to the v2 and fall back to v1 raw client.
Note
Medium Risk
Touches core client initialization and request dispatch by changing how
self._raw_clientis resolved, which could affect any call path relying on raw client behavior. The change is localized but impacts both sync and async clients.Overview
Fixes
ClientV2/AsyncClientV2losing access to legacy v1 raw-client methods (e.g.generate_stream) due to both v1 and v2 initializers overwritingself._raw_client.Introduces a
_CombinedRawClientproxy that delegates attribute access to the v2 raw client first and falls back to the captured v1 raw client, and updates both sync and async V2 client constructors to wrap_raw_clientwith this proxy after initialization.Written by Cursor Bugbot for commit abbaf21. This will update automatically on new commits. Configure here.