Skip to content

fix: raise NotFoundError on 404 from chained .get() without ID#755

Open
vdusek wants to merge 1 commit intomasterfrom
fix/chained-get-404
Open

fix: raise NotFoundError on 404 from chained .get() without ID#755
vdusek wants to merge 1 commit intomasterfrom
fix/chained-get-404

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented Apr 22, 2026

Follow-up to #737 (comment)

.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 PR 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.

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Apr 22, 2026
@vdusek vdusek self-assigned this Apr 22, 2026
@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Apr 22, 2026
@github-actions github-actions Bot added this to the 139th sprint - Tooling team milestone Apr 22, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Apr 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.19%. Comparing base (a6daff7) to head (8b6773d).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...apify_client/_resource_clients/_resource_client.py 50.00% 2 Missing ⚠️
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     
Flag Coverage Δ
integration 95.19% <50.00%> (-0.37%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek requested review from Pijukatel and janbuchar April 22, 2026 08:33
`.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.
@vdusek vdusek force-pushed the fix/chained-get-404 branch from 84e57c0 to 8b6773d Compare April 22, 2026 08:35
Copy link
Copy Markdown
Contributor

@janbuchar janbuchar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants