plandex-ai/plandex · error
failed to parse the proposed content: %v
Error message
failed to parse the proposed content: %v
What it means
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.
Source
Thrown at app/server/syntax/structured_edits_tree_sitter.go:104
}
}
}
proposedWithNormalizedComments := strings.Join(proposedLines, "\n")
res.Proposed = proposedWithNormalizedComments
originalBytes := []byte(original)
proposedBytes := []byte(proposedWithNormalizedComments)
originalTree, err := parser.ParseCtx(ctx, nil, originalBytes)
if err != nil {
return nil, fmt.Errorf("failed to parse the original content: %v", err)
}
defer originalTree.Close()
proposedTree, err := parser.ParseCtx(ctx, nil, proposedBytes)
if err != nil {
return nil, fmt.Errorf("failed to parse the proposed content: %v", err)
}
defer proposedTree.Close()
if verboseLogging {
fmt.Printf("anchorLines: %v\n", anchorLines)
}
oRes := BuildNodeIndex(originalTree)
pRes := BuildNodeIndex(proposedTree)
originalNodesByLineIndex := oRes.nodesByLine
proposedNodesByLineIndex := pRes.nodesByLine
originalParentsByLineIndex := oRes.parentsByLine
findNextAnchor := func(s string, pLineNum int, pNode *tree_sitter.Node, fromLine int) *tsAnchor {
oLineNum, ok := anchorLines[pLineNum]
if ok {
if verboseLogging {View on GitHub (pinned to e2d772072e)
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
Example fix
// before
res, err := edits.ApplyChanges(path, original, proposed)
// after
if vres, err := syntax.ValidateWithParsers(lang, proposed, parsers); err != nil || (vres != nil && vres.ParseHasError) {
return fmt.Errorf("proposed edit invalid, skipping apply")
}
res, err := edits.ApplyChanges(path, original, proposed) Defensive patterns
Strategy: validation
Validate before calling
vres, err := syntax.ValidateWithParsers(lang, proposed, parsers)
if err != nil || vres == nil || vres.ParseHasError {
return fmt.Errorf("proposed edit does not parse; regenerate")
} Type guard
func proposedEditParses(lang shared.Language, proposed string, parsers []*syntax.Parser) bool {
res, err := syntax.ValidateWithParsers(lang, proposed, parsers)
return err == nil && res != nil && !res.ParseHasError
} Try / catch
res, err := ApplyChanges(path, original, proposed)
if err != nil && strings.Contains(err.Error(), "failed to parse the proposed content") {
return retryWithCorrectedEdit(path, original, proposed) // ask model to fix syntax
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: LLM-proposed edits with malformed syntax or wrong-language snippets; normalization step corrupting code; wrong parser selected for the file; cancellation during long parses.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse the original content: %v
- failed to parse the content: %v
- error mapping file %s: %v
- failed to parse file: %v
- failed to parse the content with fallback parser: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/c60311e99d52b8bb.
Report an issue: GitHub.