theonedev/onedev · error · TooGeneralQueryException
File query is too general: ${term}
Error message
File query is too general: ${term} What it means
FileQueryOption.applyConstraints builds a Lucene wildcard query over blob names for code file searches. If the term consists only of wildcard/separator characters ('?', '*', ',', '.') with no real literal characters, matching would scan everything, so TooGeneralQueryException is thrown to protect the index from a degenerate query.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/code/query/FileQueryOption.java:58
return term;
}
public boolean isCaseSensitive() {
return caseSensitive;
}
public void applyConstraints(BooleanQuery.Builder builder) {
Preconditions.checkNotNull(term);
boolean tooGeneral = true;
for (char ch: term.toCharArray()) {
if (ch != '?' && ch != '*' && ch != ',' && ch != '.') {
tooGeneral = false;
break;
}
}
if (tooGeneral)
throw new TooGeneralQueryException("File query is too general: " + term);
builder.add(new WildcardQuery(new Term(BLOB_NAME.name(), term.toLowerCase())), BooleanClause.Occur.MUST);
}
@Nullable
public Optional<LinearRange> matches(String blobName, @Nullable String excludeFileName) {
Preconditions.checkNotNull(term);
var normalizedTerm = term;
var normalizedBlobName = blobName;
var normalizedExcludeFileName = excludeFileName;
if (!caseSensitive) {
normalizedBlobName = normalizedBlobName.toLowerCase();
normalizedTerm = normalizedTerm.toLowerCase();
if (normalizedExcludeFileName != null)
normalizedExcludeFileName = normalizedExcludeFileName.toLowerCase();
}
if (WildcardUtils.matchString(normalizedTerm, normalizedBlobName)View on GitHub (pinned to d44925c47c)
Solutions
- Include at least one literal character (letter or digit) in the search term, e.g. '*.java' instead of '*.*'.
- Validate the term client-side before submitting: reject terms matching ^[?*,.]+$ .
- Catch TooGeneralQueryException in the search entry point and show a 'query too general' message.
Example fix
// before
new FileQuery().withOption(new FileQueryOption("*.*", false));
// after
new FileQuery().withOption(new FileQueryOption("*.java", false)); Defensive patterns
Strategy: validation
Validate before calling
if (term == null || term.matches("[?*,.]+"))
throw new IllegalArgumentException("File search term needs at least one literal character"); Type guard
boolean isUsableFileTerm(String term) {
return term != null && term.chars().anyMatch(c -> "?*,.".indexOf(c) < 0);
} Try / catch
try {
query = new FileQuery().withOption(new FileQueryOption(term, caseSensitive));
} catch (TooGeneralQueryException e) {
return Result.error("File query too general: " + term);
} Prevention
- Require at least one alphanumeric character in file search terms
- Keep wildcard + extension in the term (e.g. '*.java') rather than bare wildcards
- Validate search terms in UI before submission
When it happens
Trigger: Creating a FileQueryOption with a term like '*', '??', '*.*' (only wildcards and dots/commas, no letters/digits) and applying it during a code file search, either programmatically or via the code search UI.
Common situations: User types '*' or '*.*' into the file-name code search box; a saved search contains only wildcards; programmatic search built from user input without pre-validation.
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
Related errors
- Symbol query is too general: ${term}
- Text query is too general: ${term}
- Regex query is too general: ${regex}
- Title is required
- Count should not be greater than ${RestConstants.MAX_PAGE_SI
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/ac2c82806be2153c.
Report an issue: GitHub.