Skip to content

fix(knowledge): say what went wrong when a document's chunks fail to load - #6858

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/chunk-load-error-visibility
Aug 19, 2026
Merged

fix(knowledge): say what went wrong when a document's chunks fail to load#6858
waleedlatif1 merged 2 commits into
stagingfrom
fix/chunk-load-error-visibility

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Found while surveying empty states for #6855.

const combinedError = documentError || searchError || initialError collapsed three different failures into one. On any of them the page blanked the rows, stripped search, sort and filter — and said nothing. A failed read rendered as an empty table, which is exactly what the page shows when a document genuinely has no chunks.

Stripping the search box was the worse half. When it was the search that failed, the one control the user needed to clear it was the control that disappeared. The error was a dead end.

Telling the three apart

The document itself failed. There is no page left to draw, so it gets a full screen — the same treatment the base page already gives a missing knowledge base one level up.

This has to run before the editor branches. selectedChunkId renders the chunk editor without checking for a document, and its inner guard falls through to "Loading chunk…" — so a deep link to a chunk of a deleted document sat on a spinner forever.

A chunk read failed. The document is fine, so the page keeps its chrome and all its controls, and the message goes in the table body through the emptyState slot. The search box surviving is the point: that is the recovery path.

It is tinted with --text-error. At the muted weight the empty states use, a failure is indistinguishable from "nothing here yet" — a softer version of the bug being fixed.

A search failed. The loaded chunks are still intact, so claiming the chunks could not be loaded would be untrue. It says the search failed.

A hole in the same class

const searchError = searchQueryError instanceof Error ? searchQueryError.message : null

A rejection that is not an Error instance produced no message, so chunkError stayed falsy and the table went silently blank — the exact bug this PR removes. It uses getErrorMessage now, which is what the chunk read beside it always did, and what global.md requires.

Also

  • Pagination is dropped on a failed read; it was counting pages nothing fetched. The action bar reads the same value, so it no longer lifts itself 72px clear of a bar that is not rendered.
  • The breadcrumb's 'Error' label is gone. It is unreachable by construction now — a missing document early-returns, and in every other case the document name is known and correct. Replacing a correct name with "Error" was the bug, not a feature.
  • The not-found screen was about to exist in two files, so it moves to ResourceNotFound and the base page adopts it. More detail routes are coming.

Verification

Type-check, biome, 29/29 audits, 2220 tests. The error state was rendered in both themes rather than eyeballed from the markup.

…load

`combinedError = documentError || searchError || initialError` collapsed three
different failures into one, blanked the rows and stripped search, sort and
filter — and said nothing. A failed read rendered as an empty table, which is
the same thing the page shows when a document genuinely has no chunks.

Stripping the search box was the worse half: when it was the *search* that
failed, the control the user needed to clear it was the one that disappeared.

The three are now told apart:

- The document itself failing has no page left to draw, so it gets a full
  screen, matching the base page's 'Knowledge base not found' one level up.
  It has to run before the editor branches — `selectedChunkId` renders the
  chunk editor without checking for a document, so a deep link to a chunk of a
  deleted document sat on 'Loading chunk…' forever.
- A failed chunk read keeps the document, so it keeps the chrome and the
  controls, and the message goes in the table body through the `emptyState`
  slot. Tinted with the error token, because at the weight the empty states use
  a failure is indistinguishable from 'nothing here yet'.
- A failed search leaves the loaded chunks intact, so it says the search
  failed rather than claiming the chunks could not be loaded.

`searchError` went through `instanceof Error ? .message : null`, so a rejection
that was not an `Error` produced no message and fell back to the silent blank
this commit exists to remove. It uses `getErrorMessage` now, like the chunk
read beside it always did.

Pagination is dropped on a failed read — it was counting pages nothing fetched
— and the action bar reads the same value, so it no longer lifts itself clear
of a bar that is not there.

The not-found screen was about to be copied a second time, so it moves to
`ResourceNotFound` and the base page adopts it.
@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 19, 2026 8:07pm

Request Review

@cursor

cursor Bot commented Aug 19, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Knowledge document UI and empty-state handling only; no API, auth, or data-layer changes.

Overview
Replaces the document page’s combined error handling with three distinct UX paths so failures are visible and recoverable instead of looking like an empty chunk list.

Missing document — Early return with shared ResourceNotFound (same pattern as the knowledge base page), including before chunk-editor branches so deep links to deleted documents no longer spin on “Loading chunk…”.

Chunk load vs search failure — When the document exists but chunk data or search fails, the table keeps search, sort, filter, and headers; ChunkLoadError fills the table emptyState with error styling and either “Couldn’t load chunks” or “Search failed”. Search errors now use getErrorMessage so non-Error rejections still surface.

Pagination / chrome — Pagination and the action bar offset are cleared on chunk read errors; breadcrumbs no longer swap the document name for an “Error” crumb.

Adds ResourceNotFound as a shared full-page not-found component and wires the knowledge base detail page to use it instead of inline markup.

Reviewed by Cursor Bugbot for commit 8a4fc0c. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR separates document, chunk-load, and search failures so each renders an appropriate recoverable error state.

  • Adds a reusable full-page ResourceNotFound component and adopts it for missing knowledge bases and documents.
  • Keeps document controls available when chunk loading or searching fails while rendering the error inside the table.
  • Normalizes non-Error search failures with getErrorMessage and suppresses pagination during failed reads.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code failure identified.

The revised branches preserve recovery controls for chunk and search failures, render missing documents before editor states, and retain the existing knowledge-base not-found presentation through a shared component.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx Separates document and chunk-query failures, adds descriptive table error states, preserves recovery controls, and handles missing documents before editor branches.
apps/sim/app/workspace/[workspaceId]/components/resource/resource-not-found.tsx Introduces a typed reusable full-page missing-resource presentation component.
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx Replaces duplicated missing-knowledge-base markup with the shared component without changing its content.
apps/sim/app/workspace/[workspaceId]/components/index.ts Exports the new shared missing-resource component through the workspace component barrel.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Document page] --> B{Document request failed<br/>with no document data?}
  B -->|Yes| C[Render ResourceNotFound]
  B -->|No| D{Chunk load or search failed?}
  D -->|Yes| E[Keep page controls and chrome]
  E --> F[Render ChunkLoadError in table body]
  D -->|No| G[Render chunk rows and pagination]
Loading

Reviews (1): Last reviewed commit: "fix(knowledge): say what went wrong when..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx Outdated
A document that is not `completed` rejects the chunk read by design —
`requireChunkReadable` throws `KnowledgeDocumentNotReadyError` before it queries
anything — so `initialError` is set for every pending, processing or failed
document. Treating that as a load failure put "Couldn't load chunks" over a
document that is simply still working.

`chunkRows` already builds the right row for those states, and it turns out
nothing could ever see it: the old `combinedError` blanked the rows on exactly
the same condition, so "Document processing pending..." has been unreachable
for as long as it has existed. Excluding not-ready documents from `chunkError`
brings the row back and leaves the error state for reads that genuinely failed.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8a4fc0c. Configure here.

@waleedlatif1
waleedlatif1 merged commit 936e1ac into staging Aug 19, 2026
29 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/chunk-load-error-visibility branch August 19, 2026 20:20
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