{"record":{"id":"03b0333908d87ad8","repo":"theonedev/onedev","slug":"unexpected-operator-operator-03b033","errorCode":null,"errorMessage":"Unexpected operator ${operator}","messagePattern":"Unexpected operator (.+?)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/project/ProjectQuery.java","lineNumber":204,"sourceCode":"\t\t\t\t\t\t\t\t\t\t\tcriterias.add(new PathCriteria(value, operator));\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\t\tcriterias.add(new LabelCriteria(getLabelSpec(value), operator));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase IsGreaterThan:\n\t\t\t\t\t\t\t\tcase IsLessThan:\n\t\t\t\t\t\t\t\t\tcriterias.add(new IdCriteria(getLongValue(value), operator));\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase Contains:\n\t\t\t\t\t\t\t\t\tcriterias.add(new DescriptionCriteria(value));\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase IsUntil:\n\t\t\t\t\t\t\t\tcase IsSince:\n\t\t\t\t\t\t\t\t\tcriterias.add(new LastActivityDateCriteria(value, operator));\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Unexpected operator \" + getRuleName(operator));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn operator==IsNot? Criteria.andCriterias(criterias): Criteria.orCriterias(criterias);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<Project> visitOrCriteria(OrCriteriaContext ctx) {\n\t\t\t\t\t\tList<Criteria<Project>> childCriterias = new ArrayList<>();\n\t\t\t\t\t\tfor (CriteriaContext childCtx: ctx.criteria())\n\t\t\t\t\t\t\tchildCriterias.add(visit(childCtx));\n\t\t\t\t\t\treturn new OrCriteria<>(childCriterias);\n\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<Project> visitAndCriteria(AndCriteriaContext ctx) {\n\t\t\t\t\t\tList<Criteria<Project>> childCriterias = new ArrayList<>();\n\t\t\t\t\t\tfor (CriteriaContext childCtx: ctx.criteria())\n\t\t\t\t\t\t\tchildCriterias.add(visit(childCtx));","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/project/ProjectQuery.java#L186-L222","documentation":"In visitFieldOperatorValueCriteria, each supported (field, operator) pair is mapped to a criteria class via a switch; an operator that is not valid for the given field falls through to the default branch and throws ExplicitException('Unexpected operator <name>').","triggerScenarios":"A project query like 'name is-since \"x\"' where the operator token is grammatically valid but not implemented for that specific field.","commonSituations":"Users typing operators valid for other entity types (e.g. 'submitted since') on project fields; auto-generated queries after operator renames between versions.","solutions":["Use an operator supported for the field (check ProjectQuery.checkField's switch for allowed pairs).","For date fields use Is/IsUntil/IsSince as appropriate; for name use ==/!=/contains.","Catch ExplicitException and surface 'operator X not supported for field Y' to the user.","Consult getRuleName output to map the numeric token back to the operator keyword."],"exampleFix":"// before\n\"name is-since \\\"2024-01-01\\\"\"  // operator invalid for name\n// after\n\"last activity is-since \\\"2024-01-01\\\"\"","handlingStrategy":"validation","validationCode":"ProjectQuery.checkField(fieldName, operatorToken); // throws with details before parse-time","typeGuard":"null","tryCatchPattern":"try { q = ProjectQuery.parse(text); } catch (ExplicitException e) { displayOperatorError(e); }","preventionTips":["Verify field/operator pairs against ProjectQuery.checkField's switch","Use operator reference docs per entity type","Validate user-entered queries at save time","Handle operator renames when upgrading OneDev"],"tags":["parsing","query","validation"],"backgroundTag":"invalid-enum-value","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"}