Skip to content

[Bug]: File preview read errors omit the attempted full path and failure reason #14491

Closed

Description

@josephv123

Before submitting

  • I searched existing issues and did not find a duplicate of this error-reporting problem.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web (also desktop, which uses the web file preview); packages/contracts and apps/server supply the error.

Problem

When a chat file link points to a missing or malformed path, the Files panel only reports Failed to read workspace file '<relative path>' in '<workspace>'. It does not show the full path attempted or explain whether the failure was a missing file, a permission problem, or another read error. Users cannot readily distinguish a bad agent-authored link from a T3 file-preview failure.

Steps to reproduce

  1. Open a project whose workspace root is /Users/<user>/CMU/33120.
  2. Create film-critique/outline.md inside that workspace. Ensure there is no nested 33120/film-critique/outline.md.
  3. Have an assistant message contain [outline.md](33120/film-critique/outline.md) and click the rendered file chip.
  4. The link resolves to /Users/<user>/CMU/33120/33120/film-critique/outline.md, and the read fails.

Expected behavior

The preview error should show the full attempted path and the underlying reason when known. For example, for a confirmed missing-file error:

File not found
/Users/<user>/CMU/33120/33120/film-critique/outline.md

Relative file links are resolved from /Users/<user>/CMU/33120.
Check the link's path or locate the file in Files.

If a likely duplicated workspace prefix is highlighted, present it as a possible path mistake rather than claiming the intended file is known. Permission and other read failures should retain their own explanations.

This issue is scoped to informative errors. Automatic path rewriting or fallback file selection can be considered separately.

Actual behavior

The screenshot supplied with the report shows only:

Failed to read workspace file '33120/film-critique/outline.md' in '/Users/<user>/CMU/33120'.

The breadcrumb repeats 33120, but there is no explanation of the attempted absolute path or underlying failure.

Impact

Minor bug or occasional failure. A malformed link leaves users unsure what failed and how to open the file.

Version or commit

Screenshot's release version is unknown. Source investigated at bd89c1302026255c62cc09278207bfaf2664da4a.

Environment and evidence

The supplied screenshot uses a macOS workspace path; exact client/version and connection mode are unknown. Executing the current link resolver with the example inputs reproduced the duplicated absolute path. The original message and actual file location on the Mac were not available, so the original filesystem failure reason remains unconfirmed. No browser verification was performed.

Investigation pointers

  • ProjectReadFileError carries structured context such as resolvedPath, operation, and operationPath, but its fallback message only includes the relative path and workspace.
  • projectFilesQueryState.ts reduces the read error to a message string; FilePreviewPanel.tsx renders that string.
  • Apply shared error improvements consistently to web/desktop and any mobile consumers of the same read-file contract. Display paths from the connected environment.

Related path-resolution reports: #8251 and #10553. This report concerns diagnosing failed reads, independently of how links are resolved.

Workaround

Locate the file in Files, or ask the agent for an absolute path or a correctly workspace-relative link such as film-critique/outline.md.

Activity

  1. juliusmarminge commented on Sep 30, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    Triage

    Confirmed on bd89c130. The server already tells the preview which path it tried and why the read failed, but the preview throws that away and shows only the generic message. This isn't a duplicate of #8251 or #10553 (both open issues). The fix here should be a better error message, not rewriting the path.

    projects.readFile returns a ProjectReadFileError with failure, operation, operationPath, and resolvedPath. A missing workspace file comes back as failure: "operation_failed" with operation: "realpath-target", and the joined absolute path is on both resolvedPath and operationPath. The public message is only Failed to read workspace file '<relative>' in '<cwd>'. on purpose. The constructor and packages/contracts/src/project.test.ts keep the underlying cause out of the message so raw platform error text never reaches the user.

    The Files panel then drops everything else. useProjectFileQuery keeps only cause.message and special-cases failure === "path_not_file" so a directory opens the tree. FilePreviewPanel renders that one string. Desktop uses the same preview. Mobile doesn't show this read error at all.

    Suggested fix:

    • Show the attempted path from resolvedPath or operationPath.
    • Add a short explanation for each existing code: path_not_file, binary_file, workspace_path_outside_root, resolved_path_outside_root, and a generic read failure.
    • Don't print cause.message.
    • Don't label operation_failed with realpath-target as "file not found". The same operation also covers permission errors and other realpath failures.
    • Stick to the fields that already exist. Closed PR fix(server): name the missing file instead of a generic read failure #7628 was turned down for adding a new wire failure value while describing a message-only change, so a new ProjectFileFailure value would need a clear compatibility plan for older clients.

    A hint about a duplicated workspace prefix would be a nice extra, but it should be worded as a possible mistake in the link, and the preview shouldn't open a different file. Opening the chip at a different path is what #8251 and #10553 cover. Open PR #8254 only changes slash-path lookup and doesn't touch this error.

  2. added
    bugSomething is broken or behaving incorrectly.
    via-triageFiled through npx t3 triage
    on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions