Skip to content

[Fix] Daytona read_file returns FileNotFoundError for missing files - #1693

Merged
CREDO23 merged 2 commits into
MODSetter:devfrom
CREDO23:fix/daytona-read-file-not-found
Aug 18, 2026
Merged

[Fix] Daytona read_file returns FileNotFoundError for missing files#1693
CREDO23 merged 2 commits into
MODSetter:devfrom
CREDO23:fix/daytona-read-file-not-found

Conversation

@CREDO23

@CREDO23 CREDO23 commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Map Daytona's FILE_NOT_FOUND failures in read_file to FileNotFoundError, matching the SandboxSession contract OpenSandbox already fulfills — a missing receipt no longer escapes as a raw DaytonaError and crashes the stream on the first verification
  • Re-raise all other DaytonaErrors unchanged

Test plan

  • uv run pytest tests/unit/sandbox/test_daytona_provider.py

High-level PR Summary

This PR fixes a bug in the Daytona sandbox provider where read_file operations for missing files were raising raw DaytonaError exceptions instead of the expected FileNotFoundError. The fix introduces a helper function _is_not_found that detects file-not-found conditions from Daytona errors (checking for DaytonaNotFoundError subclass, 404 status codes, and FILE_NOT_FOUND in the error message) and properly translates them to FileNotFoundError to match the SandboxSession contract. This prevents crashes during receipt verification when files are missing.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/tests/unit/sandbox/test_daytona_provider.py
2 surfsense_backend/app/sandbox/providers/daytona.py

Need help? Join our Discord

…_file

Daytona's daemon returns a FILE_NOT_FOUND body as a plain DaytonaError
(sometimes typed DaytonaNotFoundError) instead of raising FileNotFoundError.
read_receipt only catches FileNotFoundError, so a missing receipt on the first
verification crashed the stream. Translate not-found failures to
FileNotFoundError to match the SandboxSession contract OpenSandbox already
fulfills; re-raise all other DaytonaErrors unchanged.
Assert read_file surfaces a FILE_NOT_FOUND body as FileNotFoundError and still
propagates unrelated DaytonaErrors.
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

@CREDO23 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dd70a07c-897e-47fa-bf38-741b3fd3dac9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CREDO23
CREDO23 merged commit 02e6a33 into MODSetter:dev Aug 18, 2026
7 of 10 checks passed
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