{"record":{"id":"521429d94eb8e644","repo":"quarkusio/quarkus","slug":"cannot-generate-web-links-for-the-class-because-i","errorCode":null,"errorMessage":"Cannot generate web links for the class  because it has multiple fields annotated with `@RestLinkId`, where a maximum of one is allowed","messagePattern":"Cannot generate web links for the class  because it has multiple fields annotated with `@RestLinkId`, where a maximum of one is allowed","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":256,"sourceCode":"     * @throws IllegalStateException if the classname does not contain any sort of field identifier\n     */\n    private void validateRec(IndexView index, String entityType, ClassInfo classInfo) {\n        List<FieldInfo> fieldsNamedId = classInfo.fields().stream()\n                .filter(f -> f.name().equals(\"id\"))\n                .toList();\n\n        List<AnnotationInstance> fieldsAnnotatedWithId = classInfo.fields().stream()\n                .flatMap(f -> f.annotations().stream())\n                .filter(a -> a.name().toString().endsWith(\"persistence.Id\"))\n                .toList();\n\n        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) {","sourceCodeStart":238,"sourceCodeEnd":274,"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#L238-L274","documentation":"rest-links requires exactly one identifier per entity class so it can build a link path parameter. validateRec throws IllegalStateException when an entity has more than one field annotated with @RestLinkId, since the link id would be ambiguous.","triggerScenarios":"Annotating two or more fields of the same entity (or the same class in its hierarchy) with @RestLinkId; e.g. adding @RestLinkId to a new field while a base class already has one.","commonSituations":"Refactoring entities with inheritance; copy-pasting the annotation onto multiple id-like fields (id, uuid, code).","solutions":["Keep exactly one @RestLinkId field in the entity hierarchy; remove it from the other field(s).","Alternatively annotate a different existing field with @Id or name it `id` and drop the extra @RestLinkId.","Re-run the build to confirm only one id source is detected."],"exampleFix":"// before\nclass User { @RestLinkId var id: Long; @RestLinkId var username: String }\n// after\nclass User { @RestLinkId var id: Long; var username: String }","handlingStrategy":"validation","validationCode":"val ids = entityClass.declaredFields.count { it.isAnnotationPresent(RestLinkId::class.java) }\ncheck(ids <= 1) { \"@RestLinkId must appear at most once per hierarchy\" }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One identifier annotation per class hierarchy","Audit inherited fields before adding @RestLinkId"],"tags":["build-time","rest-links","annotations"],"backgroundTag":"ambiguous-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"}