{"record":{"id":"8c3c343b2f5d595e","repo":"charmbracelet/crush","slug":"symbol-s-not-found-in-grep-results","errorCode":null,"errorMessage":"symbol '%s' not found in grep results","messagePattern":"symbol '(.+?)' not found in grep results","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/lsp_helpers.go","lineNumber":64,"sourceCode":"}\n\n// resolveSymbolResults greps for a symbol and returns all viable\n// {client, path, position} tuples. Callers that need just one match\n// (definition, rename, call hierarchy) use resolveSymbol; callers that\n// want to iterate all matches (references) use this directly.\nfunc resolveSymbolResults(ctx context.Context, lspManager *lsp.Manager, symbol, workingDir string) ([]*resolvedSymbol, error) {\n\tlspManager.Start(ctx, workingDir)\n\n\t// Use word boundaries to avoid matching inside larger identifiers\n\t// (e.g. \"Bar\" inside \"myBar\"). The symbol is already QuoteMeta'd\n\t// so dots and other regex metacharacters are escaped.\n\tpattern := `\\b` + regexp.QuoteMeta(symbol) + `\\b`\n\tmatches, _, err := searchFiles(ctx, pattern, workingDir, \"\", 100)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to search for symbol: %w\", err)\n\t}\n\tif len(matches) == 0 {\n\t\treturn nil, fmt.Errorf(\"symbol '%s' not found in grep results\", symbol)\n\t}\n\n\tvar results []*resolvedSymbol\n\tfor _, match := range matches {\n\t\tabsPath, err := filepath.Abs(match.path)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tclient := findLSPClient(lspManager, absPath)\n\t\tif client == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tresults = append(results, &resolvedSymbol{\n\t\t\tclient: client,\n\t\t\tpath:   absPath,\n\t\t\tline:   match.lineNum,","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/agent/tools/lsp_helpers.go#L46-L82","documentation":"After grep completes without error, resolveSymbolResults requires at least one textual match to locate the symbol. If the word-boundary pattern \\\\b<symbol>\\\\b matches nothing, it reports the symbol was not found in grep results, since no file can be handed to the LSP client.","triggerScenarios":"Calling resolveSymbol for an identifier that literally does not appear in the working directory files — misspelled symbol, symbol defined in an ignored/vendor directory excluded by gitignore/crushignore, or only appearing in binary files grep skips.","commonSituations":"Typos in the symbol name, symbol defined in generated or vendored code filtered out by the walker, symbol renamed in the working tree while an old session still references it.","solutions":["Verify spelling and case of the symbol.","Check the symbol isn't excluded by .gitignore/.crushignore or the include filter; widen the search if so.","Search manually with the grep tool to confirm the symbol's presence.","If the symbol lives in dependencies, open the dependency file directly rather than relying on grep-based resolution."],"exampleFix":"// before\nresolveSymbol(ctx, \"UsrServc\", dir) // typo\n// after\nresolveSymbol(ctx, \"UserService\", dir)","handlingStrategy":"fallback","validationCode":"hits, _, err := searchFiles(ctx, \"\\\\b\"+regexp.QuoteMeta(sym)+\"\\\\b\", dir, \"\", 1)\nif err == nil && len(hits) == 0 {\n    // symbol genuinely absent; fix name first\n}","typeGuard":"null","tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"not found in grep\") { /* verify spelling or search wider */ }\n}","preventionTips":["Confirm exact identifier spelling and case","Account for gitignore/crushignore exclusions hiding matches","Check whether the symbol only exists in vendored/generated code"],"tags":["lsp","grep","not-found"],"backgroundTag":"symbol-not-found","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}