{"record":{"id":"b10fac59b14f65ab","repo":"quarkusio/quarkus","slug":"links-context-has-not-been-initialized","errorCode":null,"errorMessage":"Links context has not been initialized","messagePattern":"Links context has not been initialized","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-links/runtime/src/main/java/io/quarkus/resteasy/reactive/links/runtime/RestLinksProviderImpl.java","lineNumber":87,"sourceCode":"        return builder;\n    }\n\n    private Object[] getPathParameterValues(LinkInfo linkInfo, Object instance) {\n        List<Object> values = new ArrayList<>(linkInfo.getPathParameters().size());\n        for (String name : linkInfo.getPathParameters()) {\n            GetterAccessor accessor = getterAccessorsContainer.get(linkInfo.getEntityType(), name);\n            if (accessor != null) {\n                values.add(accessor.get(instance));\n            } else {\n                values.add(\"{\" + name + \"}\");\n            }\n        }\n        return values.toArray();\n    }\n\n    private void verifyInit() {\n        if (linksContainer == null) {\n            throw new IllegalStateException(\"Links context has not been initialized\");\n        }\n        if (getterAccessorsContainer == null) {\n            throw new IllegalStateException(\"Getter accessors container has not been initialized\");\n        }\n    }\n}\n","sourceCodeStart":69,"sourceCodeEnd":94,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-links/runtime/src/main/java/io/quarkus/resteasy/reactive/links/runtime/RestLinksProviderImpl.java#L69-L94","documentation":"RestLinksProviderImpl manages the REST links metadata produced by the quarkus-rest-links extension at build time. verifyInit() throws this IllegalStateException when getTypeLinks()/getInstanceLinks() are invoked before the deployment-time initialization step has populated the links container. In a properly built Quarkus application this never happens; it indicates the provider is being used outside an initialized REST links context.","triggerScenarios":"Calling RestLinksProvider.get() then getTypeLinks(...) or getInstanceLinks(...) when the RestLinksRecorder never ran or did not inject the links container (e.g. non-Quarkus test, wrong classloader, extension not present).","commonSituations":"Unit-testing code that depends on RestLinksProvider without bootstrapping Quarkus; using the provider in a plain Java SE context; the rest-links deployment module missing from the application so the recorder never initializes the containers.","solutions":["Ensure the application depends on quarkus-rest-links (runtime + deployment) so the build-time recorder initializes the links context","Only call getTypeLinks/getInstanceLinks after Quarkus startup (e.g. from a request handler or @Observes StartupEvent), not from static init","For tests, use @QuarkusTest so the full container boots and initializes the provider","Guard usage: check that you are inside a booted Quarkus application before accessing the provider"],"exampleFix":"// before\nRestLinks restLinks = RestLinksProvider.get().getTypeLinks(MyDto.class);\n// after (only after startup)\nvoid onStart(@Observes StartupEvent ev) {\n    RestLinks restLinks = RestLinksProvider.get().getTypeLinks(MyDto.class);\n}","handlingStrategy":"validation","validationCode":"RestLinksProvider provider = RestLinksProvider.get();\n// rely on @QuarkusTest bootstrapping; defensively:\nif (!isQuarkusBooted()) throw new SkipException(\"Rest links not initialized\");","typeGuard":"boolean linksReady(RestLinksProvider p) {\n    try { p.getTypeLinks(Object.class); return true; }\n    catch (IllegalStateException e) { return false; }\n}","tryCatchPattern":"try {\n    links = RestLinksProvider.get().getTypeLinks(type);\n} catch (IllegalStateException e) {\n    LOG.warn(\"REST links context unavailable\", e);\n    links = List.of();\n}","preventionTips":["Always access RestLinksProvider after application startup, never in static initializers","Use @QuarkusTest for any test touching REST links","Keep the quarkus-rest-links dependency (runtime + deployment) in the module","Never instantiate RestLinksProviderImpl manually"],"tags":["resteasy-reactive","rest-links","initialization","lifecycle"],"backgroundTag":"not-initialized","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}