fix: raise NotFoundError on 404 from chained .get() without ID#755
fix: raise NotFoundError on 404 from chained .get() without ID#755
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #755 +/- ##
==========================================
- Coverage 95.55% 95.19% -0.37%
==========================================
Files 45 45
Lines 5152 5156 +4
==========================================
- Hits 4923 4908 -15
- Misses 229 248 +19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
`.get()` previously collapsed every 404 into `None` via `catch_not_found_or_throw`. That works for direct, ID-identified fetches (`client.dataset(id).get()`), where a 404 unambiguously means the named resource is missing. It's misleading for chained calls that target a default sub-resource without an ID (`run.dataset()`, `run.key_value_store()`, `run.request_queue()`, `run.log()`): a 404 there could mean the parent run is missing or the default sub-resource is missing, and the API body cannot disambiguate the two. This change keeps the `None` behavior for ID-identified clients and propagates `NotFoundError` from chained clients (`self._resource_id is None`). The v3 upgrade guide is updated to document the new semantics, and sync/async tests cover both code paths.
84e57c0 to
8b6773d
Compare
Pijukatel
left a comment
There was a problem hiding this comment.
Should this also be applied to more than just GET methods?
For example DELETE?
Also there are probably more such endpoints where this could be applied, for example ScheduleClient.get_log
There was a problem hiding this comment.
Also could you please test the special cases like
client.actor('actor-id').last_run().dataset().get()
Where cases should be:
- missing actor -> raise 404
- existing actor, but missing last run -> raise 404
- existing actor, existing run, missing dataset -> return None
- everything exists -> return dataset (probably already tested somewhere)
Follow-up to #737 (comment)
.get()previously collapsed every 404 intoNoneviacatch_not_found_or_throw. That works for direct, ID-identified fetches (client.dataset(id).get()), where a 404 unambiguously means the named resource is missing. It's misleading for chained calls that target a default sub-resource without an ID (run.dataset(),run.key_value_store(),run.request_queue(),run.log()): a 404 there could mean the parent run is missing or the default sub-resource is missing, and the API body cannot disambiguate the two.This PR keeps the
Nonebehavior for ID-identified clients and propagatesNotFoundErrorfrom chained clients (self._resource_id is None). The v3 upgrade guide is updated to document the new semantics, and sync/async tests cover both code paths.