import { useState } from "react"; import { ChevronDown, ChevronRight } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert"; import { Button } from "@/src/components/ui/button"; import { type BulkDatasetItemValidationError } from "@langfuse/shared"; type CsvImportValidationErrorProps = { errors: BulkDatasetItemValidationError[]; }; export const CsvImportValidationError: React.FC< CsvImportValidationErrorProps > = ({ errors }) => { const [isExpanded, setIsExpanded] = useState(false); const errorCount = errors.length; const hasMoreThan10 = errorCount >= 10; // Backend might limit errors return ( Schema Validation Failed

{hasMoreThan10 ? `${errorCount}+ items failed validation. Showing first ${errorCount} errors.` : `${errorCount} item${errorCount === 1 ? "" : "s"} failed validation.`}

The CSV data does not match the required schema for this dataset. Fix the errors in your CSV file and try importing again.

{isExpanded && (
{errors.map((error, idx) => (
#{idx + 1} CSV Row {error.itemIndex + 2}:{" "} {error.field === "input" ? "Input" : "Expected Output"}
    {error.errors.map((err, errIdx) => (
  • {err.path !== "/" && ( {err.path}:{" "} )} {err.message}
  • ))}
))} {hasMoreThan10 && (

Fix these errors to see if there are additional validation issues.

)}
)}
); };