{"record":{"id":"c60311e99d52b8bb","repo":"plandex-ai/plandex","slug":"failed-to-parse-the-proposed-content-v","errorCode":null,"errorMessage":"failed to parse the proposed content: %v","messagePattern":"failed to parse the proposed content: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/syntax/structured_edits_tree_sitter.go","lineNumber":104,"sourceCode":"\t\t\t}\n\t\t}\n\t}\n\n\tproposedWithNormalizedComments := strings.Join(proposedLines, \"\\n\")\n\tres.Proposed = proposedWithNormalizedComments\n\n\toriginalBytes := []byte(original)\n\tproposedBytes := []byte(proposedWithNormalizedComments)\n\n\toriginalTree, err := parser.ParseCtx(ctx, nil, originalBytes)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse the original content: %v\", err)\n\t}\n\tdefer originalTree.Close()\n\n\tproposedTree, err := parser.ParseCtx(ctx, nil, proposedBytes)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse the proposed content: %v\", err)\n\t}\n\tdefer proposedTree.Close()\n\n\tif verboseLogging {\n\t\tfmt.Printf(\"anchorLines: %v\\n\", anchorLines)\n\t}\n\n\toRes := BuildNodeIndex(originalTree)\n\tpRes := BuildNodeIndex(proposedTree)\n\n\toriginalNodesByLineIndex := oRes.nodesByLine\n\tproposedNodesByLineIndex := pRes.nodesByLine\n\toriginalParentsByLineIndex := oRes.parentsByLine\n\n\tfindNextAnchor := func(s string, pLineNum int, pNode *tree_sitter.Node, fromLine int) *tsAnchor {\n\t\toLineNum, ok := anchorLines[pLineNum]\n\t\tif ok {\n\t\t\tif verboseLogging {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/syntax/structured_edits_tree_sitter.go#L86-L122","documentation":"The counterpart of error 765: ExecApplyTreeSitter also parses the proposed (edited, comment-normalized) content. If that ParseCtx call fails, it returns 'failed to parse the proposed content: %v'. The proposed edit text itself could not be represented as a valid syntax tree for the chosen language.","triggerScenarios":"The model/editor-generated proposedWithNormalizedComments text contains code invalid for the language, so tree-sitter's ParseCtx errors (or the context is cancelled/limit hit) during ApplyChanges → ExecApplyTreeSitter.","commonSituations":"LLM-proposed edits with malformed syntax or wrong-language snippets; normalization step corrupting code; wrong parser selected for the file; cancellation during long parses.","solutions":["Inspect the proposed content around the edit for syntax errors and regenerate/correct the edit","Validate the proposed snippet with ValidateWithParsers before applying","Ensure the correct language parser is selected for the file","Check the wrapped '%v' for timeout/cancellation and increase limits"],"exampleFix":"// before\nres, err := edits.ApplyChanges(path, original, proposed)\n// after\nif vres, err := syntax.ValidateWithParsers(lang, proposed, parsers); err != nil || (vres != nil && vres.ParseHasError) {\n    return fmt.Errorf(\"proposed edit invalid, skipping apply\")\n}\nres, err := edits.ApplyChanges(path, original, proposed)","handlingStrategy":"validation","validationCode":"vres, err := syntax.ValidateWithParsers(lang, proposed, parsers)\nif err != nil || vres == nil || vres.ParseHasError {\n    return fmt.Errorf(\"proposed edit does not parse; regenerate\")\n}","typeGuard":"func proposedEditParses(lang shared.Language, proposed string, parsers []*syntax.Parser) bool {\n    res, err := syntax.ValidateWithParsers(lang, proposed, parsers)\n    return err == nil && res != nil && !res.ParseHasError\n}","tryCatchPattern":"res, err := ApplyChanges(path, original, proposed)\nif err != nil && strings.Contains(err.Error(), \"failed to parse the proposed content\") {\n    return retryWithCorrectedEdit(path, original, proposed) // ask model to fix syntax\n}","preventionTips":["Validate the proposed content before applying tree-sitter edits","Sanitize model-generated code for the target language","Ensure comment normalization doesn't break code structure","Use timeouts large enough for big proposed files"],"tags":["tree-sitter","apply-edit","parse-error","go"],"backgroundTag":"file-parse-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}