{"record":{"id":"7b1f6117a51ea8e2","repo":"langfuse/langfuse","slug":"dataset-item-has-no-input","errorCode":null,"errorMessage":"Dataset item has no input.","messagePattern":"Dataset item has no input\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"worker/src/features/experiments/utils.ts","lineNumber":80,"sourceCode":"\nconst fetchPrompt = async (promptId: string, projectId: string) => {\n  const promptService = new PromptService(prisma, redis);\n\n  const rawPrompt = await prisma.prompt.findUnique({\n    where: { id: promptId, projectId },\n  });\n\n  return promptService.resolvePrompt(rawPrompt);\n};\n\nexport const replaceVariablesInPrompt = (\n  prompt: PromptContent,\n  itemInput: Record<string, any> | null,\n  variables: string[],\n  placeholderNames: string[] = [],\n): ChatMessage[] => {\n  if (!itemInput) {\n    throw Error(\"Dataset item has no input.\");\n  }\n\n  const processContent = (content: string) => {\n    // Extract only template variables from itemInput (exclude message placeholders)\n    const filteredContext = Object.fromEntries(\n      Object.entries(itemInput).filter(\n        ([key]) => variables.includes(key) && !placeholderNames.includes(key),\n      ),\n    );\n\n    // Apply template ONLY if the content contains `{{variable}}` pattern\n    if (content.includes(\"{{\")) {\n      return compileTemplateString(content, filteredContext);\n    }\n    return content; // Return original content if no placeholders are found\n  };\n  if (typeof prompt === \"string\") {\n    return [","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/langfuse/langfuse/blob/59d92c7cf365150d10b753b5a0d1708902a2ed60/worker/src/features/experiments/utils.ts#L62-L98","documentation":"replaceVariablesInPrompt in the experiments worker requires the dataset item to have an input object; when itemInput is null it throws 'Dataset item has no input.' before building the chat messages.","triggerScenarios":"Running an experiment whose dataset contains an item with no input (null/empty), while the prompt template declares variables that must be filled from item input.","commonSituations":"Datasets with mixed items (some input-less), items created from spans without input payloads, or prompts relying on variables the dataset doesn't consistently provide.","solutions":["Clean the dataset: remove or fix items with null input before running the experiment.","Ensure ingested dataset items actually capture the input payload you map variables from.","Adjust the prompt to only use variables present in every item."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const usable = items.filter(i => i.input != null && typeof i.input === \"object\");\nif (usable.length < items.length) warnAndSkipNullInputItems();","typeGuard":"const hasInput = (item: DatasetItem): item is DatasetItem & { input: Record<string, any> } => item.input != null && typeof item.input === \"object\";","tryCatchPattern":"catch (e) { if (e.message === \"Dataset item has no input.\") reportSkippedItemAndContinue(); }","preventionTips":["Filter null-input dataset items before creating experiments","Ensure ingestion captures input payloads on dataset items","Keep prompt variables limited to fields present on every item"],"tags":["experiments","dataset","worker","validation"],"backgroundTag":"missing-required-input","analyzedSha":"59d92c7cf365150d10b753b5a0d1708902a2ed60","analyzedAt":"2026-08-27T22:22:00.402Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}