{"record":{"id":"0a220dea90774d8b","repo":"theonedev/onedev","slug":"criteria-operator-is-not-supported-here-0a220d","errorCode":null,"errorMessage":"Criteria '${operator}' is not supported here","messagePattern":"Criteria '(.+?)' is not supported here","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/pack/PackQuery.java","lineNumber":104,"sourceCode":"\t\t\tPackQueryParser parser = new PackQueryParser(tokens);\n\t\t\tparser.removeErrorListeners();\n\t\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\t\tQueryContext queryContext = parser.query();\n\t\t\tCriteriaContext criteriaContext = queryContext.criteria();\n\t\t\tCriteria<Pack> packCriteria;\n\t\t\tif (criteriaContext != null) {\n\t\t\t\tpackCriteria = new PackQueryBaseVisitor<Criteria<Pack>>() {\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<Pack> visitFuzzyCriteria(FuzzyCriteriaContext ctx) {\n\t\t\t\t\t\treturn new FuzzyCriteria(getValue(ctx.getText()));\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tpublic Criteria<Pack> visitOperatorCriteria(PackQueryParser.OperatorCriteriaContext ctx) {\n\t\t\t\t\t\tswitch (ctx.operator.getType()) {\n\t\t\t\t\t\t\tcase PublishedByMe:\n\t\t\t\t\t\t\t\tif (!withCurrentUserCriteria)\n\t\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Criteria '\" + ctx.operator.getText() + \"' is not supported here\");\n\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","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/pack/PackQuery.java#L86-L122","documentation":"When parsing a pack query, operator criteria (e.g. 'published by me') are only allowed when the parser was built with current-user criteria enabled (withCurrentUserCriteria). If such an operator appears where it is not permitted, PackQuery throws ExplicitException(\"Criteria '<operator>' is not supported here\").","triggerScenarios":"Parsing a pack query containing 'published by me' (or another operator criterion) in a context where PackQuery was constructed without the current-user criteria flag, e.g. certain parse variants or embedding sites that disallow self-referencing criteria.","commonSituations":"Using 'published by me' in a project-scoped or system-generated query context that disallows it; copying a query string from the UI into an API call that parses with different options.","solutions":["Remove the 'published by me' criterion from this query context or use 'published by <user>' instead","Parse the query via the API/entry point that enables current-user criteria if that is intended","Catch ExplicitException and show a user-facing message about the unsupported criterion"],"exampleFix":"// before\n\"published by me\" // in a context without current-user criteria\n// after\n\"published by john.doe\"","handlingStrategy":"validation","validationCode":"if (/published\\s+by\\s+me/i.test(queryString) && !currentUserCriteriaAllowed) throw new ExplicitException(\"'published by me' not allowed in this context\");","typeGuard":"null","tryCatchPattern":"try { PackQuery.parse(...); } catch (ExplicitException e) { showError(\"Criterion not supported here: use 'published by <user>'\"); }","preventionTips":["Know which parse contexts allow current-user criteria","Substitute explicit users in system/project-scoped queries","Keep query templates per context type"],"tags":["query","validation","onedev"],"backgroundTag":"unsupported-operation","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"}