{"record":{"id":"aa37d0ea5b133612","repo":"theonedev/onedev","slug":"no-agent-with-name-value","errorCode":null,"errorMessage":"\"No agent with name '\" + value + \"'\"","messagePattern":"\"No agent with name '\" \\+ value \\+ \"'\"","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/workspace/RanOnCriteria.java","lineNumber":27,"sourceCode":"import javax.persistence.criteria.Predicate;\n\nimport io.onedev.commons.utils.ExplicitException;\nimport io.onedev.server.OneDev;\nimport io.onedev.server.service.AgentService;\nimport io.onedev.server.model.Agent;\nimport io.onedev.server.model.Workspace;\nimport io.onedev.server.util.ProjectScope;\nimport io.onedev.server.util.criteria.Criteria;\n\npublic class RanOnCriteria extends Criteria<Workspace> {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\tprivate final String value;\n\t\n\tpublic RanOnCriteria(String value) {\n\t\tif (OneDev.getInstance(AgentService.class).findByName(value) == null)\n\t\t\tthrow new ExplicitException(\"No agent with name '\" + value + \"'\");\n\t\tthis.value = value;\n\t}\n\n\tpublic String getValue() {\n\t\treturn value;\n\t}\n\n\t@Override\n\tpublic Predicate getPredicate(@Nullable ProjectScope projectScope, CriteriaQuery<?> query, From<Workspace, Workspace> from, CriteriaBuilder builder) {\n\t\tJoin<?, ?> join = from.join(Workspace.PROP_AGENT, JoinType.INNER);\n\t\tjoin.on(builder.equal(join.get(Agent.PROP_NAME), value));\n\t\treturn join.isNotNull();\n\t}\n\n\t@Override\n\tpublic boolean matches(Workspace workspace) {\n\t\treturn workspace.getAgent() != null && workspace.getAgent().getName().equals(value);\n\t}","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/workspace/RanOnCriteria.java#L9-L45","documentation":"RanOnCriteria is a workspace search criterion matching workspaces that ran on a build agent. The constructor eagerly validates the agent name via AgentService.findByName and throws ExplicitException immediately if no agent with that name exists.","triggerScenarios":"Parsing a workspace query containing a 'ran on' criterion whose quoted value is not the name of any registered agent, e.g. `ran on \"nonexistent-agent\"`.","commonSituations":"Typo in agent name in a saved search query; agent was renamed, removed or never registered; query copy-pasted between OneDev instances with different agent setups.","solutions":["Check the exact agent name under OneDev admin Agents list and use it verbatim in the query.","Register or re-register the agent with the name used in the query.","Rename the agent back if it was renamed after queries were saved.","Edit saved queries that reference the old agent name."],"exampleFix":"// before\nnew RanOnCriteria(\"build-02\")  // agent renamed to builder-02\n// after\nnew RanOnCriteria(\"builder-02\")","handlingStrategy":"validation","validationCode":"var agent = OneDev.getInstance(AgentService.class).findByName(agentName);\nif (agent == null) throw new IllegalArgumentException(\"Unknown agent: \" + agentName);","typeGuard":null,"tryCatchPattern":"try {\n    var criteria = new RanOnCriteria(agentName);\n} catch (ExplicitException e) {\n    // fall back / report unknown agent name\n}","preventionTips":["Keep agent names in a shared constant/config referenced by queries","Validate agent names against AgentService before building criteria","Audit saved queries when renaming or removing agents"],"tags":["search","entity-criteria","agent"],"backgroundTag":"resource-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"}