Skip to content

fix: include file path in file errors#132

Open
nicholaspun-wandb wants to merge 1 commit into
mainfrom
npun/surface-missing-file
Open

fix: include file path in file errors#132
nicholaspun-wandb wants to merge 1 commit into
mainfrom
npun/surface-missing-file

Conversation

@nicholaspun-wandb

@nicholaspun-wandb nicholaspun-wandb commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Returns the file path in the error message when a file operation fails

Testing

Updated unit tests and ran the following script:

from wandb.sandbox import Sandbox
import wandb

wandb.login()

with Sandbox.run(
    "sh",
    "-c",
    "sleep 60",
    container_image="python:3.11-slim",
    max_lifetime_seconds=120,
) as sb:
    print("sandbox_id", sb.sandbox_id)
    sb.wait(timeout=120)
    sb.read_file("/tmp/sandbox-e2e-missing-file.txt").result(timeout=60)

Before (only File operation failed displayed to the user):

uv run python missing_file_repro.py
wandb: [wandb.login()] Loaded credentials for https://api.wandb.ai from /Users/nicholaspun/.netrc.
wandb: Currently logged in as: nicholas-pun (wandb) to https://api.wandb.ai. Use `wandb login --relogin` to force relogin
sandbox_id b4be58e0-6257-4ce4-80be-689256bff5c8
Traceback (most recent call last):
  File "/Users/nicholaspun/Documents/test-wb-sandbox/.venv/lib/python3.11/site-packages/cwsandbox/_sandbox.py", line 3773, in _read_file_async
    response = await self._stub.RetrieveFile(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ...
    raise _translate_rpc_error(
cwsandbox.exceptions.SandboxFileError: File operation failed (CWSANDBOX_FILE_NOT_FOUND): peer Gateway returned RetrieveFile error: peer RetrieveFile returned error: rpc error: code = NotFound desc = 

After (File operation failed for '/tmp/sandbox-e2e-missing-file.txt' surfaced):

PYTHONPATH=/Users/nicholaspun/Documents/cwsandbox-client/src uv run python missing_file_repro.py
wandb: [wandb.login()] Loaded credentials for https://api.wandb.ai from /Users/nicholaspun/.netrc.
wandb: Currently logged in as: nicholas-pun (wandb) to https://api.wandb.ai. Use `wandb login --relogin` to force relogin
sandbox_id 3ca54f50-c94b-4e19-a8b4-d4fb9459bc3f
Traceback (most recent call last):
  File "/Users/nicholaspun/Documents/cwsandbox-client/src/cwsandbox/_sandbox.py", line 3905, in _read_file_unary_async
    response = await self._stub.RetrieveFile(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ...
  File "/Users/nicholaspun/Documents/cwsandbox-client/src/cwsandbox/_sandbox.py", line 3909, in _read_file_unary_async
    raise _translate_rpc_error(
cwsandbox.exceptions.SandboxFileError: File operation failed for '/tmp/sandbox-e2e-missing-file.txt' (CWSANDBOX_FILE_NOT_FOUND): peer Gateway returned RetrieveFile error: peer RetrieveFile returned error: rpc error: code = NotFound desc = 

@nicholaspun-wandb nicholaspun-wandb self-assigned this May 26, 2026
@nicholaspun-wandb nicholaspun-wandb requested a review from a team as a code owner May 26, 2026 22:12
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