Skip to content

PIM-7684: Recover raises RecoverError when files_processed is 0#351

Open
udirctera wants to merge 3 commits into
masterfrom
PIM-7684-recover-raise-on-zero-files
Open

PIM-7684: Recover raises RecoverError when files_processed is 0#351
udirctera wants to merge 3 commits into
masterfrom
PIM-7684-recover-raise-on-zero-files

Conversation

@udirctera
Copy link
Copy Markdown
Collaborator

@udirctera udirctera commented May 10, 2026

Summary

Override _task_complete in the Recover command class to raise RecoverError when files_processed == 0.

Why is this needed?

The SDK's _handle_response dispatches based on task status:

  • failed_task_error → raises RecoverError
  • completed_with_warnings_task_error → raises RecoverError
  • completed_task_complete → returns success (list of paths) — no error check

The problem: when recovering files that no longer exist in trash, the Portal can return the task with status completed but files_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 if files_processed == 0. If so, we route to _task_error which raises RecoverError — consistent with how failed and completed_with_warnings are handled.

Test plan

  • All 696 SDK unit tests pass
  • Deployed to Portal VM and verified:
    • Recover of deleted file → success
    • Recover of non-existent file → RecoverError raised

udirctera and others added 3 commits May 10, 2026 11:52
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant