{"record":{"id":"d1e7860b287b5e4d","repo":"plandex-ai/plandex","slug":"error-getting-diffs-v","errorCode":null,"errorMessage":"error getting diffs: %v","messagePattern":"error getting diffs: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/model/plan/build_validate_and_fix.go","lineNumber":209,"sourceCode":"\tauthVars := fileState.authVars\n\tmodelConfig := params.modelConfig\n\n\toriginalFile := params.originalFile\n\tupdated := params.updated\n\tproposedContent := params.proposedContent\n\tdesc := params.desc\n\tonStream := params.onStream\n\tsyntaxErrors := params.syntaxErrors\n\treasons := params.reasons\n\n\tbaseModelConfig := modelConfig.GetBaseModelConfig(authVars, fileState.settings, fileState.orgUserConfig)\n\n\t// Get diff for validation\n\tlog.Printf(\"Getting diffs between original and updated content\")\n\tdiff, err := diff_pkg.GetDiffs(originalFile, updated)\n\tif err != nil {\n\t\tlog.Printf(\"Error getting diffs: %v\", err)\n\t\treturn buildValidateResult{}, fmt.Errorf(\"error getting diffs: %v\", err)\n\t}\n\n\toriginalWithLineNums := shared.AddLineNums(originalFile)\n\tproposedWithLineNums := shared.AddLineNums(proposedContent)\n\n\tmaxExpectedOutputTokens := shared.GetNumTokensEstimate(originalFile)/2 + shared.GetNumTokensEstimate(proposedContent)\n\n\t// Choose prompt and tools based on preferred format\n\n\tlog.Printf(\"Building XML validation replacements prompt\")\n\tpromptText, headNumTokens := prompts.GetValidationReplacementsXmlPrompt(prompts.ValidationPromptParams{\n\t\tPath:                 filePath,\n\t\tOriginalWithLineNums: originalWithLineNums,\n\t\tDesc:                 desc,\n\t\tProposedWithLineNums: proposedWithLineNums,\n\t\tDiff:                 diff,\n\t\tSyntaxErrors:         syntaxErrors,\n\t\tReasons:              reasons,","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/build_validate_and_fix.go#L191-L227","documentation":"Inside buildValidate, before sending content to the model for validation, the code computes a diff between the original and updated file via diff_pkg.GetDiffs(originalFile, updated). If this fails the error is wrapped as \"error getting diffs: %v\" and buildValidate returns immediately, failing the current validation attempt. It is a local diffing failure preceding any LLM call.","triggerScenarios":"diff_pkg.GetDiffs(originalFile, updated) returns a non-nil error — typically undiffable content (binary-looking or invalid-UTF-8 LLM output, empty/nil content, huge files) or an internal failure of the diff package.","commonSituations":"A previous repair step produced mangled output (null bytes, mixed encodings) that the differ cannot process; diff package version change; file so large the diff algorithm exceeds limits or times out.","solutions":["Log/inspect the inner error and sanity-check both originalFile and updated (length, UTF-8 validity) before calling GetDiffs.","Sanitize or truncate the updated content; reject obviously invalid LLM output earlier in the pipeline.","Upgrade or patch the diff package if the error traces inside it.","Fall back to a no-diff validation mode (send full files without line-numbered diff) when diffing fails."],"exampleFix":"// before\ndiff, err := diff_pkg.GetDiffs(originalFile, updated)\nif err != nil {\n    return buildValidateResult{}, fmt.Errorf(\"error getting diffs: %v\", err)\n}\n// after\nif !utf8.ValidString(updated) || updated == \"\" {\n    return buildValidateResult{}, fmt.Errorf(\"updated content invalid, skipping diff\")\n}\ndiff, err := diff_pkg.GetDiffs(originalFile, updated)\nif err != nil {\n    log.Printf(\"GetDiffs failed (%v); proceeding without diff context\", err)\n    diff = \"\"\n}","handlingStrategy":"validation","validationCode":"func diffable(original, updated string) error {\n    if original == \"\" || updated == \"\" {\n        return fmt.Errorf(\"empty content\")\n    }\n    if !utf8.ValidString(original) || !utf8.ValidString(updated) {\n        return fmt.Errorf(\"non-UTF-8 content\")\n    }\n    if strings.ContainsRune(updated, 0) {\n        return fmt.Errorf(\"null bytes in updated content\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"diff, err := diff_pkg.GetDiffs(originalFile, updated)\nif err != nil {\n    log.Printf(\"GetDiffs failed: %v; continuing validation without diff\", err)\n    diff = \"\"\n}","preventionTips":["Validate UTF-8 and reject null bytes in LLM output before diffing.","Cap file sizes fed into the diff algorithm.","Test the diff package against binary-ish and mixed-line-ending inputs.","Design validation to degrade to full-file context when a diff is unavailable."],"tags":["diff","validation","build-pipeline"],"backgroundTag":"diff-computation-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}