{"record":{"id":"e656153d6b70767b","repo":"plandex-ai/plandex","slug":"failed-to-parse-file-v","errorCode":null,"errorMessage":"failed to parse file: %v","messagePattern":"failed to parse file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/syntax/file_map/multi.go","lineNumber":105,"sourceCode":"\t\t\tvar parser *tree_sitter.Parser\n\t\t\tfile := filepath.Base(path)\n\t\t\tif strings.Contains(strings.ToLower(file), \"dockerfile\") {\n\t\t\t\tparser = syntax.GetParserForLanguage(shared.LanguageDockerfile)\n\t\t\t} else {\n\t\t\t\tparser, _, _, _ = syntax.GetParserForPath(path)\n\n\t\t\t\tif parser == nil {\n\t\t\t\t\terrCh <- fmt.Errorf(\"unsupported file type: %s\", path)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcontentBytes := []byte(content)\n\n\t\t\t// Parse file\n\t\t\ttree, err := parser.ParseCtx(ctx, nil, contentBytes)\n\t\t\tif err != nil {\n\t\t\t\terrCh <- fmt.Errorf(\"failed to parse file: %v\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefer tree.Close()\n\n\t\t\tmu.Lock()\n\t\t\tdefer mu.Unlock()\n\t\t\ttrees[path] = string(tree.RootNode().String())\n\t\t\terrCh <- nil\n\t\t}(path, content)\n\t}\n\n\tfor i := 0; i < len(inputs); i++ {\n\t\terr := <-errCh\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/syntax/file_map/multi.go#L87-L123","documentation":"After resolving a parser, multi.go parses each file's bytes with parser.ParseCtx(ctx, nil, contentBytes). If the tree-sitter parse itself fails (e.g. context cancellation, operation/timeout limit), the goroutine wraps it as 'failed to parse file: %v'.","triggerScenarios":"ParseCtx returns a non-nil error while concurrently mapping a file — most commonly ctx cancellation/timeout or hitting the operation limit on very large files.","commonSituations":"Mapping huge generated files under a context deadline; parent context cancelled mid-batch; resource limits reached during concurrent parsing of many large files.","solutions":["Inspect the wrapped '%v' cause; if it is a timeout/operation-limit, increase limits or parse in chunks","Increase the context deadline or remove cancellation for long batches","Exclude very large/generated files from mapping","Lower concurrency (semaphore size) to reduce resource pressure"],"exampleFix":"// before\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n// after\nctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)\nMultiMapFile(ctx, paths)","handlingStrategy":"fallback","validationCode":"if len(content) > maxParseSize {\n    return fmt.Errorf(\"file %s too large to map (%d bytes)\", path, len(content))\n}\nif ctx.Err() != nil {\n    return ctx.Err()\n}","typeGuard":null,"tryCatchPattern":"err := <-errCh\nif err != nil && strings.Contains(err.Error(), \"failed to parse file\") {\n    if strings.Contains(err.Error(), \"operation limit\") || strings.Contains(err.Error(), \"timeout\") {\n        // retry with larger limits or skip large file\n    }\n}","preventionTips":["Set generous context deadlines for large batch parses","Exclude generated/minified/huge files","Bound concurrency so parses don't exhaust resources","Check ctx.Err() before dispatching each file"],"tags":["tree-sitter","parse-timeout","go","concurrency"],"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"}