OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
fix: a status with no entry no longer takes down the knowledge view (#2468)
Rico Furtadof810b787f2af
diff --git a/frontend/app/knowledge/page.test.tsx b/frontend/app/knowledge/page.test.tsxindex 1f7bed36d..6d194d3e8 100644--- a/frontend/app/knowledge/page.test.tsx+++ b/frontend/app/knowledge/page.test.tsx@@ -307,6 +307,27 @@ describe("StatusCellContent", () => {setRecentTasksExpanded: noop,};+ it("renders a file skipped for a duplicate filename without crashing", () => {+ // The row a blocked overwrite leaves behind: skipped, but not for+ // duplicate_content, so it falls past SkippedStatusCell to the plain+ // badge. "skipped" had no entry there, and the throw took the whole+ // knowledge view down (tracker #92808).+ render(+ <TooltipProvider>+ <StatusCellContent+ {...baseProps}+ data={f({+ status: "skipped",+ skip_reason: "duplicate_filename",+ warning: "A file with this name already exists.",+ })}+ />+ </TooltipProvider>,+ );++ expect(screen.getByText("Skipped")).toBeTruthy();+ });+it("renders a StatusBadge for an active file", () => {render(<TooltipProvider>diff --git a/frontend/app/knowledge/page.tsx b/frontend/app/knowledge/page.tsxindex 52a4cfceb..0c51c8045 100644--- a/frontend/app/knowledge/page.tsx+++ b/frontend/app/knowledge/page.tsx@@ -384,11 +384,7 @@ export function StatusCellContent({return <SkippedStatusCell warning={data?.warning} />;}- return (- <StatusBadge- status={status as import("@/components/ui/status-badge").Status}- />- );+ return <StatusBadge status={status} />;}export function resolveActionsVariant(diff --git a/frontend/components/ui/status-badge.test.tsx b/frontend/components/ui/status-badge.test.tsxnew file mode 100644index 000000000..1fc3d3f4b--- /dev/null+++ b/frontend/components/ui/status-badge.test.tsx@@ -0,0 +1,50 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it } from "vitest";+import { StatusBadge } from "./status-badge";++/**+ * This badge reads its label and colour out of a lookup keyed by status, and+ * callers take that status straight off an API response. When a file arrived+ * as "skipped" — which has no entry — the unguarded `statusConfig[status]+ * .className` threw, React's error boundary caught it, and the whole knowledge+ * view was replaced by "Component rendering error" (tracker #92808).+ *+ * A presentational badge must not be able to take a page down, whatever the+ * backend sends.+ */++describe("StatusBadge", () => {+ it("renders the mapped label for a known status", () => {+ render(<StatusBadge status="active" />);+ expect(screen.getByText("Active")).toBeTruthy();+ });++ it("renders a skipped file rather than throwing", () => {+ render(<StatusBadge status="skipped" />);+ expect(screen.getByText("Skipped")).toBeTruthy();+ });++ it("renders an unmapped status as its own name", () => {+ render(<StatusBadge status="queued" />);+ expect(screen.getByText("Queued")).toBeTruthy();+ });++ it("humanises a multi-word unmapped status", () => {+ render(<StatusBadge status="in_progress" />);+ expect(screen.getByText("In progress")).toBeTruthy();+ });++ it("falls back to a label when the status is empty", () => {+ render(<StatusBadge status="" />);+ expect(screen.getByText("Unknown")).toBeTruthy();+ });++ it("keeps the caller's className alongside the status colour", () => {+ const { container } = render(+ <StatusBadge status="failed" className="pointer-events-none" />,+ );+ const el = container.firstElementChild as HTMLElement;+ expect(el.className).toContain("pointer-events-none");+ expect(el.className).toContain("text-accent-red-foreground");+ });+});diff --git a/frontend/components/ui/status-badge.tsx b/frontend/components/ui/status-badge.tsxindex 356194ac9..23836403a 100644--- a/frontend/components/ui/status-badge.tsx+++ b/frontend/components/ui/status-badge.tsx@@ -10,10 +10,16 @@ export type Status =| "cancelled"| "ready"| "fallback"- | "not-configured";+ | "not-configured"+ | "skipped";interface StatusBadgeProps {- status: Status;+ /**+ * A known status, or any other string an API response can carry. Callers+ * read this straight off a file or task record, so the set is not ours to+ * close — `Status` exists for autocomplete, not as a guarantee.+ */+ status: Status | (string & {});className?: string;}@@ -58,21 +64,40 @@ const statusConfig = {label: "Not configured",className: "text-muted-foreground ",},+ skipped: {+ label: "Skipped",+ className: "text-muted-foreground ",+ },};+/** Title-cases a status this badge has no entry for: "in_progress" → "In progress". */+function labelForUnknownStatus(status: string): string {+ const spaced = status.replace(/[_-]+/g, " ").trim();+ return spaced ? spaced.charAt(0).toUpperCase() + spaced.slice(1) : "Unknown";+}+export const StatusBadge = ({ status, className }: StatusBadgeProps) => {- const config = statusConfig[status];+ // A status with no entry here renders as its own name rather than throwing.+ // This read used to be `statusConfig[status].className`, which took the whole+ // page down through the error boundary the first time a file arrived as+ // "skipped" — a presentational badge is never a good reason to lose the view+ // it sits in, and the set of statuses the API can send is not fixed.+ const config = statusConfig[status as Status] as+ | { label: string; className: string }+ | undefined;+ const label = config?.label ?? labelForUnknownStatus(status);+ const statusClassName = config?.className ?? "text-muted-foreground ";return (<div- className={`inline-flex items-center gap-1 ${config.className} ${+ className={`inline-flex items-center gap-1 ${statusClassName} ${className || ""}`}>{status === "processing" && (<AnimatedProcessingIcon className="text-current shrink-0" />)}- {config.label}+ {label}</div>);};