PIM-7684: Recover raises RecoverError when files_processed is 0#351
Open
udirctera wants to merge 3 commits into
Open
PIM-7684: Recover raises RecoverError when files_processed is 0#351udirctera wants to merge 3 commits into
udirctera wants to merge 3 commits into
Conversation
Override _task_complete in Recover to detect edge case where portal reports task as completed but processed zero files, ensuring RecoverError is raised consistently for all failure modes. Co-authored-by: Cursor <cursoragent@cursor.com>
The consolidation in 932ed19 made `objects` a required parameter in the async CloudDrive.handle() but optional in the sync version. This broke callers that use handle(path) for single-file reads. Co-authored-by: Cursor <cursoragent@cursor.com>
This reverts commit 29463a3.
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.
Summary
Override
_task_completein theRecovercommand class to raiseRecoverErrorwhenfiles_processed == 0.Why is this needed?
The SDK's
_handle_responsedispatches based on task status:failed→_task_error→ raisesRecoverError✔completed_with_warnings→_task_error→ raisesRecoverError✔completed→_task_complete→ returns success (list of paths) — no error checkThe problem: when recovering files that no longer exist in trash, the Portal can return the task with status
completedbutfiles_processed = 0. Without this check, the SDK reports success to the caller even though nothing was actually recovered.This means callers (like the MCP) would tell the user "Recovered: [path]" when in reality the file was not recovered.
What does the fix do?
Before delegating to the parent
_task_complete(which returns the path list as success), we check iffiles_processed == 0. If so, we route to_task_errorwhich raisesRecoverError— consistent with howfailedandcompleted_with_warningsare handled.Test plan
RecoverErrorraised