{"record":{"id":"91064248ade1e9b9","repo":"theonedev/onedev","slug":"symbol-query-is-too-general-term","errorCode":null,"errorMessage":"Symbol query is too general: ${term}","messagePattern":"Symbol query is too general: (.+?)","errorType":"validation","errorClass":"TooGeneralQueryException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/code/query/SymbolQueryOption.java","lineNumber":124,"sourceCode":"\t\t\n\t\tif (fileNames != null) {\n\t\t\tBooleanQuery.Builder subQueryBuilder = new BooleanQuery.Builder();\n\t\t\tfor (String pattern: Splitter.on(\",\").omitEmptyStrings().trimResults().split(fileNames.toLowerCase()))\n\t\t\t\tsubQueryBuilder.add(new WildcardQuery(new Term(BLOB_NAME.name(), pattern)), SHOULD);\n\t\t\tBooleanQuery subQuery = subQueryBuilder.build();\n\t\t\tif (subQuery.clauses().size() != 0)\n\t\t\t\tbuilder.add(subQuery, MUST);\n\t\t}\n\n\t\tboolean tooGeneral = true;\n\t\tfor (char ch: term.toCharArray()) {\n\t\t\tif (ch != '?' && ch != '*') {\n\t\t\t\ttooGeneral = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (tooGeneral)\n\t\t\tthrow new TooGeneralQueryException(\"Symbol query is too general: \" + term);\n\n\t\tif (primary != null) {\n\t\t\tString fieldName;\n\t\t\tif (primary)\n\t\t\t\tfieldName = BLOB_PRIMARY_SYMBOLS.name();\n\t\t\telse\n\t\t\t\tfieldName = BLOB_SECONDARY_SYMBOLS.name();\n\n\t\t\tbuilder.add(new WildcardQuery(new Term(fieldName, term.toLowerCase())), MUST);\n\t\t} else {\n\t\t\tBooleanQuery.Builder termQueryBuilder = new BooleanQuery.Builder();\n\t\t\ttermQueryBuilder.add(new WildcardQuery(new Term(BLOB_PRIMARY_SYMBOLS.name(), term.toLowerCase())), SHOULD);\n\t\t\ttermQueryBuilder.add(new WildcardQuery(new Term(BLOB_SECONDARY_SYMBOLS.name(), term.toLowerCase())), SHOULD);\n\t\t\tbuilder.add(termQueryBuilder.build(), MUST);\n\t\t}\n\t}\n\n\t@Override","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/code/query/SymbolQueryOption.java#L106-L142","documentation":"SymbolQueryOption.applyConstraints indexes a symbol search term into Lucene fields. If the term contains only wildcard characters ('?' and '*') with no literal characters, the query would match every symbol, so TooGeneralQueryException is thrown. This prevents pathological full-scan symbol queries.","triggerScenarios":"Building a SymbolQuery whose option term is made up solely of '*' and/or '?' (e.g. '*', '???') and applying its constraints during a code symbol search.","commonSituations":"User enters '*' in the symbol search box of code search; programmatic symbol search built from unvalidated user input; a saved search left with only wildcard characters.","solutions":["Add at least one literal (non-wildcard) character to the term, e.g. 'get*' instead of '*'.","Pre-validate the term before creating the query: reject terms matching ^[?*]+$ .","Catch TooGeneralQueryException in the search path and prompt the user to refine the query."],"exampleFix":"// before\nnew SymbolQuery().withOption(new SymbolQueryOption(\"*\", false, true, true));\n// after\nnew SymbolQuery().withOption(new SymbolQueryOption(\"get*\", false, true, true));","handlingStrategy":"validation","validationCode":"if (term == null || term.matches(\"[?*]+\"))\n    throw new IllegalArgumentException(\"Symbol search term needs at least one literal character\");","typeGuard":"boolean isUsableSymbolTerm(String term) {\n    return term != null && term.chars().anyMatch(c -> c != '?' && c != '*');\n}","tryCatchPattern":"try {\n    query = new SymbolQuery().withOption(new SymbolQueryOption(term, false, true, true));\n} catch (TooGeneralQueryException e) {\n    return Result.error(\"Symbol query too general: \" + term);\n}","preventionTips":["Prefix symbols with literal text (e.g. 'get*') instead of bare wildcards","Validate terms against ^[?*]+$ before constructing SymbolQueryOption","Show a hint in the symbol search UI about minimum literal content"],"tags":["lucene","code-search","symbols"],"backgroundTag":"invalid-query-parameter","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}