theonedev/onedev · error · ExplicitException
Attribute not found:
Error message
Attribute not found:
What it means
AgentQuery.checkField validates that a criteria field is either one of QUERY_FIELDS or a defined agent attribute name; otherwise it throws ExplicitException "Attribute not found: <field>". It is invoked from field-operator-value criteria visiting.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/agent/AgentQuery.java:238
agentSort.setDirection(DESCENDING);
else
agentSort.setDirection(ASCENDING);
} else {
agentSort.setDirection(sortField.getDefaultDirection());
}
agentSorts.add(agentSort);
}
return new AgentQuery(agentCriteria, agentSorts);
} else {
return new AgentQuery();
}
}
public static void checkField(String fieldName, int operator) {
var attributeNames = OneDev.getInstance(AgentAttributeService.class).getAttributeNames();
if (!QUERY_FIELDS.contains(fieldName) && !attributeNames.contains(fieldName))
throw new ExplicitException("Attribute not found: " + fieldName);
}
public static String getRuleName(int rule) {
return AntlrUtils.getLexerRuleName(AgentQueryLexer.ruleNames, rule);
}
public static int getOperator(String operatorName) {
return AntlrUtils.getLexerRule(AgentQueryLexer.ruleNames, operatorName);
}
public static AgentQuery merge(AgentQuery baseQuery, AgentQuery query) {
List<Criteria<Agent>> criterias = new ArrayList<>();
if (baseQuery.getCriteria() != null)
criterias.add(baseQuery.getCriteria());
if (query.getCriteria() != null)
criterias.add(query.getCriteria());
List<EntitySort> sorts = new ArrayList<>(query.getSorts());
sorts.addAll(baseQuery.getSorts());View on GitHub (pinned to d44925c47c)
Solutions
- Define the attribute as an agent attribute (job property 'agent attributes') so getAttributeNames() returns it
- Fix the field-name spelling
- Rewrite the query to use an existing field or attribute
Example fix
// before q = "gpu-count is \"2\"" // attribute undefined // after // set agent attribute gpu-count: 2 in job, then re-run query
Defensive patterns
Strategy: validation
Validate before calling
var attrs = OneDev.getInstance(AgentAttributeService.class).getAttributeNames();
if (!AgentQuery.QUERY_FIELDS.contains(field) && !attrs.contains(field)) throw new IllegalArgumentException("unknown field: " + field); Try / catch
try { new AgentQuery(q); } catch (ExplicitException e) { /* prompt user to define the attribute or fix the name */ } Prevention
- Define agent attributes in job scripts before querying them
- Validate field names against getAttributeNames() in the query builder UI
- Update saved queries when renaming attributes
When it happens
Trigger: Using a field in an agent query value criterion (e.g. 'gpu is "yes"') where the name matches neither built-in query fields nor any existing agent attribute — attribute deleted, typo, or attribute defined in another project.
Common situations: Renaming/removing an agent attribute that saved queries still reference; typo in the attribute name; assuming arbitrary fields are queryable.
Related errors
- Error parsing query
- Malformed query
- Criteria '' is not supported here
- Unexpected operator:
- Cannot order by field:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/966ccadcaeec7d18.
Report an issue: GitHub.