Repository navigation
Description
In plain words
OSS: The file viewer opens any file, including images and PDFs, and shows an error when one fails to load.
OHE: Files that are not plain text can arrive garbled, and a file that fails to load shows up empty.
Outcome and scope
Inventory: G10, G11. Feature IDs: F08.files-rich-plain, F08.files-fallbacks, F08.files-load-error, F08.files-open-new-window.
Provide tenant-authorized bytes/MIME/status-preserving download or equivalent safe runtime transport. Current /file decodes UTF-8 and failures can become empty strings. Supply minimal authenticated stable asset-base seam for existing rich-preview issue; do not enable scripts for parity.
Pinned source evidence
enterprise/openhands/app_server/app_conversation/app_conversation_router.py
Lines 1350 to 1448 in 0a67aa4
app_conversation_service: AppConversationService = ( app_conversation_service_dependency ), sandbox_service: SandboxService = sandbox_service_dependency, sandbox_spec_service: SandboxSpecService = sandbox_spec_service_dependency, ) -> str: """Read a file from a specific conversation's sandbox workspace. Returns the content of the file at the specified path if it exists, otherwise returns an empty string. Args: conversation_id: The UUID of the conversation file_path: Path to the file to read within the sandbox workspace Returns: The content of the file or an empty string if the file doesn't exist """ # Get the conversation info conversation = await app_conversation_service.get_app_conversation(conversation_id) if not conversation: return '' # Get the sandbox info sandbox = await sandbox_service.get_sandbox(conversation.sandbox_id) if not sandbox or sandbox.status != SandboxStatus.RUNNING: return '' # Get the sandbox spec to find the working directory sandbox_spec = await sandbox_spec_service.get_sandbox_spec(sandbox.sandbox_spec_id) if not sandbox_spec: return '' # Get the agent server URL if not sandbox.exposed_urls: return '' agent_server_url = None for exposed_url in sandbox.exposed_urls: if exposed_url.name == AGENT_SERVER: agent_server_url = exposed_url.url break if not agent_server_url: return '' agent_server_url = replace_localhost_hostname_for_docker(agent_server_url) # Create remote workspace remote_workspace = AsyncRemoteWorkspace( host=agent_server_url, api_key=sandbox.session_api_key, working_dir=sandbox_spec.working_dir, ) # The runtime's file_download requires an absolute path that already points # at the file. The frontend may have rooted ``file_path`` at its own # working-dir convention (e.g. ``/workspace/project/enterprise/...``) # rather than the runtime's actual clone location # (``{working_dir}/{repo_name}/...``); remap it onto the resolved project # dir so the download resolves the right file instead of 404-ing into "". ctx = AgentServerContext( conversation=conversation, sandbox=sandbox, sandbox_spec=sandbox_spec, agent_server_url=agent_server_url, session_api_key=sandbox.session_api_key, ) resolved_path = _resolve_file_path(file_path, ctx) # Read the file at the specified path temp_file_path = None try: # Create a temporary file path to download the remote file with tempfile.NamedTemporaryFile(mode='w+b', delete=False) as temp_file: temp_file_path = temp_file.name # Download the file from remote system result = await remote_workspace.file_download( source_path=resolved_path, destination_path=temp_file_path, ) if result.success: # Read the content from the temporary file with open(temp_file_path, 'rb') as f: content = f.read() # Decode bytes to string return content.decode('utf-8') except Exception: # If there's any error reading the file, return empty string pass finally: # Clean up the temporary file if temp_file_path: try: os.unlink(temp_file_path) except Exception: # Ignore errors during cleanup pass - https://github.com/OpenHands/OpenHands/blob/852132d38dbc15e03d6825bbacbeb971c72575be/src/hooks/query/use-workspace-file-content.ts#L185-L260
- https://github.com/OpenHands/software-agent-sdk/blob/3f26a0570e96e92c6af0b75388e31c9bf4f23efc/clients/typescript/src/client/cloud-client.ts#L578-L583
Source audit only, not a deployed-OHE test result. Canvas pins Agent Server 1.55.1 (minimum 1.51.0); Enterprise Python dependencies pin 1.50.1. Record actual app/runtime images and client versions before interpreting capability failures; Python dependencies do not establish deployed sandbox version.
Dependencies and delivery order
OpenHands/software-agent-sdk#6079; reuse SDK #5650 / PR #5762 and OpenHands/OpenHands#15752. Reconcile producer PR enterprise#684 path rules first.
Acceptance
- PNG/PDF/arbitrary binary checksums round-trip, valid empty file stays successful, legacy text reads have explicit migration.
- Missing/forbidden/paused/unreachable/upstream failures stay distinguishable, never success-empty; errors redact secrets.
- Canonical/symlink containment, owner/org authorization and safe content disposition/type apply to downloads/assets; no runtime keys in browser URLs.
- Agree stable authenticated asset paths/sessions for sibling CSS/images, expiry/revocation and cross-org tests; no arbitrary filesystem origins or implicit script execution.
- Publish SDK typed download/preview before minimal Canvas migration; validate checksum, assets, denied/missing files, resume and safe new-window behavior on authorized OHE.
Duplicate reconciliation and non-goals
Existing #15752 owns preview UI; this is missing Enterprise producer, not duplicate viewer/RemoteWorkspace corruption. Pinned /file differs from older download narrative.
No profile/configuration/Apps/automation expansion. Do not duplicate SDK primitives or put backend/version compatibility into Canvas. Live validation needs authorized disposable OHE user/org/repository/runtime fixtures and redacted evidence, never credentials/customer data. Filing does not authorize deployment or production testing.
Created by OpenHands (AI agent) on behalf of Graham Neubig.
Activity
juanmichelini commentedon Nov 17, 2026
In plain words
OSS: The file viewer opens any file, including images and PDFs, and shows an error when one fails to load.
OHE: Files that are not plain text can arrive garbled, and a file that fails to load shows up empty.
This comment was posted by an AI agent (OpenHands) on behalf of juanmichelini, for the dev-coordinator status table on enterprise#1333.