{"record":{"id":"526f1e78cd633da3","repo":"quarkusio/quarkus","slug":"priority-must-be-positive","errorCode":null,"errorMessage":"`priority` must be positive","messagePattern":"`priority` must be positive","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/FilterBuildItem.java","lineNumber":72,"sourceCode":"     * Creates a new instance of {@link FilterBuildItem} with an authentication failure handler.\n     * The handler will be added as next to last, right before {@link io.quarkus.vertx.http.runtime.QuarkusErrorHandler}.\n     */\n    public static FilterBuildItem ofAuthenticationFailureHandler(Handler<RoutingContext> authFailureHandler) {\n        return new FilterBuildItem(authFailureHandler);\n    }\n\n    /**\n     * Creates a new instance of {@link FilterBuildItem} with an authentication failure handler.\n     * The handler will be added right before any handlers added by\n     * {@link FilterBuildItem#ofAuthenticationFailureHandler(Handler)}\n     */\n    public static FilterBuildItem ofPreAuthenticationFailureHandler(Handler<RoutingContext> authFailureHandler) {\n        return new FilterBuildItem(authFailureHandler, SecurityHandlerPriorities.AUTH_FAILURE_HANDLER + 1, false, true);\n    }\n\n    private void checkPriority(int priority) {\n        if (priority < 0) {\n            throw new IllegalArgumentException(\"`priority` must be positive\");\n        }\n    }\n\n    public Handler<RoutingContext> getHandler() {\n        return handler;\n    }\n\n    public int getPriority() {\n        return priority;\n    }\n\n    public boolean isFailureHandler() {\n        return isFailureHandler;\n    }\n\n    /**\n     * @return a filter object wrapping the handler and priority.\n     */","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/FilterBuildItem.java#L54-L90","documentation":"FilterBuildItem requires a non-negative integer priority used to sort HTTP filters. The checkPriority method (called from the constructor) throws IllegalArgumentException with '`priority` must be positive' when a negative priority is passed. Despite the message saying 'positive', the check is priority < 0, so zero is accepted.","triggerScenarios":"Constructing new FilterBuildItem(handler, priority) or any of(...) factory with a negative int, typically from a computed priority constant that underflows or from subtracting from a base priority past zero.","commonSituations":"Custom extensions producing FilterBuildItems with hand-computed priorities; arithmetic on priority constants (e.g. BASE - offset) that goes negative; typos in literal priorities like -10.","solutions":["Pass a non-negative priority (0 or greater) to the FilterBuildItem constructor","Clamp computed priorities: Math.max(0, basePriority - offset)","Use existing constants like SecurityHandlerPriorities to derive safe values"],"exampleFix":"// before\nnew FilterBuildItem(handler, MY_BASE_PRIORITY - 10); // negative\n\n// after\nnew FilterBuildItem(handler, Math.max(0, MY_BASE_PRIORITY - 10));","handlingStrategy":"validation","validationCode":"int priority = computePriority();\nif (priority < 0) {\n    throw new IllegalArgumentException(\"Filter priority must be >= 0, got \" + priority);\n}\nFilterBuildItem item = new FilterBuildItem(handler, priority);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp computed priorities with Math.max(0, value)","Derive priorities from published constants (e.g. SecurityHandlerPriorities) rather than literals","Assert priorities >= 0 in producer tests"],"tags":["filter","priority","validation","build-time"],"backgroundTag":"invalid-priority-value","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}