{"record":{"id":"8d3a0a5614d9d019","repo":"quarkusio/quarkus","slug":"cannot-generate-web-links-for-the-class-because-i-8d3a0a","errorCode":null,"errorMessage":"Cannot generate web links for the class  because it is either missing an `id` field, a field with an `@Id` annotation or a field with a `@RestLinkId annotation","messagePattern":"Cannot generate web links for the class  because it is either missing an `id` field, a field with an `@Id` annotation or a field with a `@RestLinkId annotation","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-links/deployment/src/main/java/io/quarkus/resteasy/reactive/links/deployment/LinksProcessor.java","lineNumber":268,"sourceCode":"        List<AnnotationInstance> fieldsAnnotatedWithRestLinkId = classInfo.fields().stream()\n                .flatMap(f -> f.annotations(RestLinkId.class).stream())\n                .toList();\n\n        // @RestLinkId annotation count > 1 is not allowed\n        if (fieldsAnnotatedWithRestLinkId.size() > 1) {\n            throw new IllegalStateException(\"Cannot generate web links for the class \" + entityType +\n                    \" because it has multiple fields annotated with `@RestLinkId`, where a maximum of one is allowed\");\n        }\n\n        // Id field found, break the loop\n        if (!fieldsNamedId.isEmpty() || !fieldsAnnotatedWithId.isEmpty() || !fieldsAnnotatedWithRestLinkId.isEmpty()) {\n            return;\n        }\n\n        // Id field not found and hope is gone\n        DotName superClassName = classInfo.superName();\n        if (superClassName == null) {\n            throw new IllegalStateException(\"Cannot generate web links for the class \" + entityType +\n                    \" because it is either missing an `id` field, a field with an `@Id` annotation or a field with a `@RestLinkId annotation\");\n        }\n\n        // Id field not found but there's still hope\n        classInfo = index.getClassByName(superClassName);\n        if (classInfo == null) {\n            throw new RuntimeException(String.format(\"Class '%s' was not found\", superClassName));\n        }\n        validateRec(index, entityType, classInfo);\n    }\n\n    /**\n     * Implement a field getter inside a class and create an accessor class which knows how to access it.\n     */\n    private void implementGetterWithAccessor(ClassOutput classOutput,\n            BuildProducer<BytecodeTransformerBuildItem> bytecodeTransformersProducer,\n            GetterMetadata getterMetadata) {\n        bytecodeTransformersProducer.produce(new BytecodeTransformerBuildItem(","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-links/deployment/src/main/java/io/quarkus/resteasy/reactive/links/deployment/LinksProcessor.java#L250-L286","documentation":"validateRec walks the entity class hierarchy looking for an `id` field, an @Id-annotated field, or a @RestLinkId field. If it exhausts the hierarchy (superName == null, i.e. java.lang.Object reached) without finding one, it throws this IllegalStateException — the class cannot be used for web links.","triggerScenarios":"Registering/using an entity class for REST links that has no field named `id`, no @Id annotation, and no @RestLinkId annotation anywhere in its inheritance chain.","commonSituations":"DTOs or key-less records used as path parameters; entities using a composite key without @RestLinkId; renaming the id field to something else.","solutions":["Add a field named `id`, or annotate the identifier field with @RestLinkId (or @Id for JPA entities).","If the class genuinely has no identity, do not generate links for it (disable rest-links for that resource).","Check inheritance: if the id is on a mapped superclass, make sure the correct hierarchy is compiled in."],"exampleFix":"// before\nclass Item(var name: String)\n// after\nclass Item(@RestLinkId var id: Long, var name: String)","handlingStrategy":"validation","validationCode":"fun hasId(c: Class<*>): Boolean = c.fields.any { it.name == \"id\" ||\n  it.isAnnotationPresent(RestLinkId::class.java) || it.isAnnotationPresent(Id::class.java) } ||\n  (c.superclass?.let { hasId(it) } ?: false)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Name the identifier field `id` or annotate it","Don't reuse id-less DTOs for link generation"],"tags":["build-time","rest-links","annotations"],"backgroundTag":"missing-identifier-field","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"}