fix(records): raise TypeError instead of leaking AttributeError for typed arguments - #2749
Draft
andersfylling wants to merge 3 commits into
Draft
fix(records): raise TypeError instead of leaking AttributeError for typed arguments#2749andersfylling wants to merge 3 commits into
andersfylling wants to merge 3 commits into
Conversation
last_updated_time, sort, sources, target_units and filter are dumped without a type check, so a raw dict or a bare string surfaces as "AttributeError: dict object has no attribute dump" from deep inside the SDK, naming neither the argument nor the expected type. The dict cases are the wire form the endpoints already accept for filter, so they should just work. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…yped arguments last_updated_time, sort, sources, target_units and filter now go through one dump helper: the typed object is dumped, a dict is passed through as the wire form it already is, and anything else raises TypeError naming the argument, the expected type and a worked example. sources and target_units also accept a single object instead of requiring a one-item sequence. The signatures are widened accordingly, so a dict is no longer a type error at the call site either, matching how instances.list already takes InstanceSort | dict. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2749 +/- ##
=======================================
Coverage 93.79% 93.79%
=======================================
Files 513 513
Lines 52445 52515 +70
=======================================
+ Hits 49189 49256 +67
- Misses 3256 3259 +3
🚀 New features to boost your workflow:
|
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.
Reported in review: passing a raw dict where a typed request object is expected fails deep inside the SDK, naming neither the argument nor the type.
last_updated_time,sort,sources,target_unitsandfilternow share one dump helper: the typed object is dumped, a dict is passed through as the wire form it already is, and anything else raises TypeError naming the argument, the expected type and a worked example.sourcesandtarget_unitsadditionally accept a single object instead of requiring a one-item sequence —target_units=RecordTargetUnit(...)used to fail with'RecordTargetUnit' object is not iterable.Accepting dicts is what makes the reported snippet work rather than merely fail better, and it matches
instances.list, which already takesInstanceSort | dict. The signatures are widened to match, so a dict is no longer a type-checker error at the call site either.First commit is the failing tests, second is the fix, including the regenerated sync client.
🤖 Generated with Claude Code