{"record":{"id":"49f6f5e375958a3d","repo":"theonedev/onedev","slug":"unexpected-criteria-operator","errorCode":null,"errorMessage":"Unexpected criteria: ${operator}","messagePattern":"Unexpected criteria: (.+?)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/pack/PackQuery.java","lineNumber":123,"sourceCode":"\t\t\t\t\t\t\t\treturn new PublishedByMeCriteria();\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Unexpected operator: \" + ctx.operator.getText());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<Pack> visitOperatorValueCriteria(PackQueryParser.OperatorValueCriteriaContext ctx) {\n\t\t\t\t\t\tvar criterias = new ArrayList<Criteria<Pack>>();\n\t\t\t\t\t\tfor (var quoted: ctx.criteriaValue.Quoted()) {\n\t\t\t\t\t\t\tString value = getValue(quoted.getText());\n\t\t\t\t\t\t\tif (ctx.PublishedByUser() != null)\n\t\t\t\t\t\t\t\tcriterias.add(new PublishedByUserCriteria(getUser(value)));\n\t\t\t\t\t\t\telse if (ctx.PublishedByBuild() != null)\n\t\t\t\t\t\t\t\tcriterias.add(new PublishedViaBuildCriteria(project, value));\n\t\t\t\t\t\t\telse if (ctx.PublishedByProject() != null)\n\t\t\t\t\t\t\t\tcriterias.add(new PublishedViaProjectCriteria(value));\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Unexpected criteria: \" + ctx.operator.getText());\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\treturn 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<Pack> visitFieldOperatorValueCriteria(FieldOperatorValueCriteriaContext ctx) {\n\t\t\t\t\t\tString fieldName = getValue(ctx.criteriaField.getText());\n\t\t\t\t\t\tint operator = ctx.operator.getType();\n\t\t\t\t\t\tcheckField(project, fieldName, operator);\n\n\t\t\t\t\t\tvar criterias = new ArrayList<Criteria<Pack>>();\n\t\t\t\t\t\tfor (var quoted: ctx.criteriaValue.Quoted()) {\n\t\t\t\t\t\t\tString value = getValue(quoted.getText());\n\t\t\t\t\t\t\tswitch (operator) {\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\tif (fieldName.equals(NAME_PUBLISH_DATE))\n\t\t\t\t\t\t\t\t\t\tcriterias.add(new PublishDateCriteria(value, operator));","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/pack/PackQuery.java#L105-L141","documentation":"In visitOperatorValueCriteria, PackQuery maps operator-value criteria like 'published by <user>', 'published by build <n>', 'published by project <x>' to concrete Criteria classes. If the operator token matches none of the known patterns, it throws ExplicitException(\"Unexpected criteria: <operator>\").","triggerScenarios":"A pack query operator-value criterion whose operator is not PublishedByUser, PublishedByBuild, or PublishedByProject — e.g. typo'd or unsupported operator with a value attached, or query text from a different grammar version.","commonSituations":"Typos like 'published by user john' vs 'published by john'; reusing issue/build query operators on pack queries; version drift between saved queries and current parser.","solutions":["Use one of the supported forms: 'published by <user>', 'published by build <n>', 'published by project <name>'","Validate the query in the UI editor before saving/calling the API","Catch ExplicitException to report the offending operator to the user"],"exampleFix":"// before\n\"published by user john\" // unsupported form\n// after\n\"published by john\"","handlingStrategy":"validation","validationCode":"const valid = /^published by (build \\d+|project \\S+|\\S+)$/i; q.split(/\\b(?:and|or)\\b/i).forEach(c => { if (/published by/i.test(c) && !valid.test(c.trim())) throw new Error('bad operator-value criterion: ' + c.trim()); });","typeGuard":"null","tryCatchPattern":"try { PackQuery.parse(project, q); } catch (ExplicitException e) { if (e.getMessage().startsWith('Unexpected criteria')) showError(e.getMessage()); else throw e; }","preventionTips":["Use exact supported forms: 'published by <user>', 'published by build <n>', 'published by project <name>'","Avoid free-form operator naming","Lint saved queries periodically"],"tags":["query","validation","onedev"],"backgroundTag":"invalid-query-parameter","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}