[Fix] Daytona read_file returns FileNotFoundError for missing files - #1693
Conversation
…_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.
|
@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. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Summary
FILE_NOT_FOUNDfailures inread_filetoFileNotFoundError, matching theSandboxSessioncontract OpenSandbox already fulfills — a missing receipt no longer escapes as a rawDaytonaErrorand crashes the stream on the first verificationDaytonaErrors unchangedTest plan
uv run pytest tests/unit/sandbox/test_daytona_provider.pyHigh-level PR Summary
This PR fixes a bug in the Daytona sandbox provider where
read_fileoperations for missing files were raising rawDaytonaErrorexceptions instead of the expectedFileNotFoundError. The fix introduces a helper function_is_not_foundthat detects file-not-found conditions from Daytona errors (checking forDaytonaNotFoundErrorsubclass, 404 status codes, andFILE_NOT_FOUNDin the error message) and properly translates them toFileNotFoundErrorto match theSandboxSessioncontract. This prevents crashes during receipt verification when files are missing.⏱️ Estimated Review Time: 5-15 minutes
💡 Review Order Suggestion
surfsense_backend/tests/unit/sandbox/test_daytona_provider.pysurfsense_backend/app/sandbox/providers/daytona.py