Repository navigation
fix: raise ResponseValidationError on invalid API responses - #1265
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1265 +/- ##
==========================================
+ Coverage 95.79% 95.88% +0.09%
==========================================
Files 65 65
Lines 6892 6950 +58
==========================================
+ Hits 6602 6664 +62
+ Misses 290 286 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Pijukatel
approved these changes
Dec 1, 2026
…tion-error # Conflicts: # src/apify_client/_resource_clients/request_queue.py
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.
Resource clients validate API responses through one helper,
validate_response(). A response that doesn't match its model raisesResponseValidationError, a subclass of bothApifyClientErrorandpydantic.ValidationError. Anexcept ApifyClientErrorhandler catches it, and existingexcept pydantic.ValidationErrororexcept ValueErrorhandlers still do.The message starts with the HTTP method and path of the request and ends with a hint to upgrade the client or report the mismatch. The method and path come from the log context that
HttpClient.call()sets. Each resource client method clears them when it starts, so a custom HTTP client that overridescall()gets an error that names no request. Log records emitted before a method's first request carry nomethodandurleither.errors()returns the same entries as the original pydantic error, which is kept as__cause__, also in asyncbatch_add_requests(). Entries thatfrom_exception_data()rejects, such as thevalue_errorfromEmailStr, are rebuilt as custom errors with the same type and message. The error keeps its method and path when pickled or copied.UserClient.get()still falls back to the public user model. When neither model matches, the error lists the mismatches against the private model, which has every public field. Validation of request input (TaskInput, request queue requests, and so on) still raises a plainValidationError.The error handling concept page gets a short section on the new error.
Closes: #1170
✍️ Drafted by Claude Code