{"record":{"id":"960099e3f071c277","repo":"quarkusio/quarkus","slug":"routebuilditem-builder-routefunction-was-not-set","errorCode":null,"errorMessage":"'RouteBuildItem$Builder.routeFunction' was not set. Ensure that one of the builder methods that result in it being set is called","messagePattern":"'RouteBuildItem\\$Builder\\.routeFunction' was not set\\. Ensure that one of the builder methods that result in it being set is called","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/RouteBuildItem.java","lineNumber":255,"sourceCode":"        }\n\n        public Builder management(String managementConfigKey) {\n            if (managementConfigKey == null || shouldInclude(managementConfigKey)) {\n                this.isManagement = true;\n            } else {\n                this.isManagement = false;\n            }\n            return this;\n        }\n\n        private boolean shouldInclude(String managementConfigKey) {\n            Config config = ConfigProvider.getConfig();\n            return config.getValue(managementConfigKey, boolean.class);\n        }\n\n        public RouteBuildItem build() {\n            if (routeFunction == null) {\n                throw new IllegalStateException(\n                        \"'RouteBuildItem$Builder.routeFunction' was not set. Ensure that one of the builder methods that result in it being set is called\");\n            }\n            return new RouteBuildItem(this, APPLICATION_ROUTE, APPLICATION_ROUTE, isManagement);\n        }\n\n        protected ConfiguredPathInfo getRouteConfigInfo() {\n            if (routeConfigKey == null) {\n                return null;\n            }\n            if (routePath == null) {\n                throw new RuntimeException(\"Cannot discover value of \" + routeConfigKey\n                        + \" as no explicit path was specified and a route function is in use\");\n            }\n            if (absolutePath != null) {\n                return new ConfiguredPathInfo(routeConfigKey, absolutePath, true, isManagement);\n            }\n            return new ConfiguredPathInfo(routeConfigKey, routePath, false, isManagement);\n        }","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/RouteBuildItem.java#L237-L273","documentation":"RouteBuildItem.Builder.build() is a state-machine guard: it refuses to produce a RouteBuildItem whose routeFunction field is null, since such an item would render a route with no handler. The builder offers several setters (route(), routeFunction(), orderedRoute(), etc.) and at least one must have been invoked. Throwing IllegalStateException at build-time surfaces the misconfigured builder to the extension author immediately.","triggerScenarios":"Calling build() on a RouteBuildItem.Builder without having called any of route(), routeFunction(), orderedRoute(), or another method that populates routeFunction — e.g. a builder created and configured only with displayOnNotFoundPage or route config key.","commonSituations":"Constructing a builder and forgetting the handler step after setting metadata; conditionally skipping the route/handler call due to a null handler bean; copy-pasting a builder chain and deleting the route(...) line.","solutions":["Call a route-producing method before build(): builder.routeFunction(\"/path\", route -> route.handler(handler)).build()","If the route is conditional, guard the whole builder creation rather than building an empty builder","Inspect your builder chain: every build() call must be preceded by exactly the route setup"],"exampleFix":"// before\nRouteBuildItem item = new RouteBuildItem.Builder().displayOnNotFoundPage(true).build();\n// after\nRouteBuildItem item = new RouteBuildItem.Builder()\n    .routeFunction(\"/q/health\", r -> r.handler(myHandler))\n    .displayOnNotFoundPage(true)\n    .build();","handlingStrategy":"validation","validationCode":"RouteBuildItem.Builder b = new RouteBuildItem.Builder()...;\nObjects.requireNonNull(routeHandler, \"handler must be set before build()\");\nRouteBuildItem item = b.routeFunction(path, r -> r.handler(routeHandler)).build();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make the routeFunction(...) call immediately precede build() in every builder chain","Return the builder from a helper that always sets the handler, so an empty builder cannot be built","If route creation is conditional, conditionally return null instead of building an unconfigured builder"],"tags":["quarkus","vertx-http","builder-misuse","routing","build-time"],"backgroundTag":"builder-state-not-initialized","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"}