{"record":{"id":"5dd93b6d46de8a8e","repo":"theonedev/onedev","slug":"no-build-in-query-context-5dd93b","errorCode":null,"errorMessage":"No build in query context","messagePattern":"No build in query context","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/issue/FixedInCurrentBuildCriteria.java","lineNumber":24,"sourceCode":"import javax.persistence.criteria.From;\nimport javax.persistence.criteria.Predicate;\n\nimport io.onedev.commons.utils.ExplicitException;\nimport io.onedev.server.model.Build;\nimport io.onedev.server.model.Issue;\nimport io.onedev.server.util.ProjectScope;\nimport io.onedev.server.util.criteria.Criteria;\n\npublic class FixedInCurrentBuildCriteria extends Criteria<Issue> {\n\n\tprivate static final long serialVersionUID = 1L;\n\t\n\t@Override\n\tpublic Predicate getPredicate(@Nullable ProjectScope projectScope, CriteriaQuery<?> query, From<Issue, Issue> from, CriteriaBuilder builder) {\n\t\tif (Build.get() != null)\n\t\t\treturn new FixedInBuildCriteria(Build.get()).getPredicate(projectScope, query, from, builder);\n\t\telse\n\t\t\tthrow new ExplicitException(\"No build in query context\");\n\t}\n\n\t@Override\n\tpublic boolean matches(Issue issue) {\n\t\tif (Build.get() != null)\n\t\t\treturn new FixedInBuildCriteria(Build.get()).matches(issue);\n\t\telse\n\t\t\tthrow new ExplicitException(\"No build in query context\");\n\t}\n\n\t@Override\n\tpublic String toStringWithoutParens() {\n\t\treturn IssueQuery.getRuleName(IssueQueryLexer.FixedInCurrentBuild);\n\t}\n\n}\n","sourceCodeStart":6,"sourceCodeEnd":41,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/issue/FixedInCurrentBuildCriteria.java#L6-L41","documentation":"FixedInCurrentBuildCriteria delegates to FixedInBuildCriteria using the build from the current query context. Its getPredicate() requires Build.get() to return a build; when the query is executed without build context, an ExplicitException with this message is thrown because there is no build to scope the 'fixed in current build' criteria to.","triggerScenarios":"Running an issue query containing 'fixed in current build' criteria outside a build context — project issue list, saved dashboard query, REST API call, or scheduled evaluation.","commonSituations":"Filters authored on a build's issue page reused globally; CI scripts issuing queries before a Build entity is registered; cron jobs evaluating queries without build scope.","solutions":["Execute the query in a build-bound context (build issue list or code that sets Build)","Replace 'fixed in current build' with 'fixed in build <number>' or an explicit commit range","Catch ExplicitException programmatically and fall back to a context-free query","Ensure the integration binds the current build before evaluating issue queries"],"exampleFix":"// before\nIssueQuery query = IssueQuery.parse(\"fixed in current build\");\nissueManager.query(project, query); // throws without build context\n// after\nBuild build = Build.get();\nIssueQuery query = IssueQuery.parse(build!=null ? \"fixed in current build\" : \"fixed in build \"+buildNumber);\nissueManager.query(project, query);","handlingStrategy":"try-catch","validationCode":"if (Build.get() == null) { throw new IllegalStateException(\"'fixed in current build' criteria requires build context\"); }","typeGuard":"boolean hasBuildContext() { return Build.get() != null; }","tryCatchPattern":"try { issues = issueManager.query(project, query); } catch (ExplicitException e) { if (e.getMessage().contains(\"build\")) { issues = queryWithoutCurrentBuildCriteria(); } else { throw e; } }","preventionTips":["Check Build.get() before running 'fixed in current build' queries","Use 'fixed in build <number>' in saved/dashboard queries","Only run this criteria from build-scoped pages or CI jobs","Bind the current Build before programmatic query evaluation"],"tags":["onedev","issue-query","build","query-context"],"backgroundTag":"missing-required-config","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"}