{"record":{"id":"966ccadcaeec7d18","repo":"theonedev/onedev","slug":"attribute-not-found","errorCode":null,"errorMessage":"Attribute not found: ","messagePattern":"Attribute not found: ","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/agent/AgentQuery.java","lineNumber":238,"sourceCode":"\t\t\t\t\t\tagentSort.setDirection(DESCENDING);\n\t\t\t\t\telse\n\t\t\t\t\t\tagentSort.setDirection(ASCENDING);\n\t\t\t\t} else {\n\t\t\t\t\tagentSort.setDirection(sortField.getDefaultDirection());\n\t\t\t\t}\n\t\t\t\tagentSorts.add(agentSort);\n\t\t\t}\n\t\t\t\n\t\t\treturn new AgentQuery(agentCriteria, agentSorts);\n\t\t} else {\n\t\t\treturn new AgentQuery();\n\t\t}\n\t}\n\n\tpublic static void checkField(String fieldName, int operator) {\n\t\tvar attributeNames = OneDev.getInstance(AgentAttributeService.class).getAttributeNames();\n\t\tif (!QUERY_FIELDS.contains(fieldName) && !attributeNames.contains(fieldName))\n\t\t\tthrow new ExplicitException(\"Attribute not found: \" + fieldName);\n\t}\n\t\n\tpublic static String getRuleName(int rule) {\n\t\treturn AntlrUtils.getLexerRuleName(AgentQueryLexer.ruleNames, rule);\n\t}\n\t\n\tpublic static int getOperator(String operatorName) {\n\t\treturn AntlrUtils.getLexerRule(AgentQueryLexer.ruleNames, operatorName);\n\t}\n\t\n\tpublic static AgentQuery merge(AgentQuery baseQuery, AgentQuery query) {\n\t\tList<Criteria<Agent>> criterias = new ArrayList<>();\n\t\tif (baseQuery.getCriteria() != null)\n\t\t\tcriterias.add(baseQuery.getCriteria());\n\t\tif (query.getCriteria() != null)\n\t\t\tcriterias.add(query.getCriteria());\n\t\tList<EntitySort> sorts = new ArrayList<>(query.getSorts());\n\t\tsorts.addAll(baseQuery.getSorts());","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/agent/AgentQuery.java#L220-L256","documentation":"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.","triggerScenarios":"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.","commonSituations":"Renaming/removing an agent attribute that saved queries still reference; typo in the attribute name; assuming arbitrary fields are queryable.","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"],"exampleFix":"// before\nq = \"gpu-count is \\\"2\\\"\" // attribute undefined\n// after\n// set agent attribute gpu-count: 2 in job, then re-run query","handlingStrategy":"validation","validationCode":"var attrs = OneDev.getInstance(AgentAttributeService.class).getAttributeNames();\nif (!AgentQuery.QUERY_FIELDS.contains(field) && !attrs.contains(field)) throw new IllegalArgumentException(\"unknown field: \" + field);","typeGuard":null,"tryCatchPattern":"try { new AgentQuery(q); } catch (ExplicitException e) { /* prompt user to define the attribute or fix the name */ }","preventionTips":["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"],"tags":["agent-attributes","query-syntax","onedev"],"backgroundTag":"attribute-not-found","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"}