{"record":{"id":"302f02c9c1d727a1","repo":"quarkusio/quarkus","slug":"should-not-be-extended-or-implemented-302f02","errorCode":null,"errorMessage":" should not be extended or implemented","messagePattern":" should not be extended or implemented","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/panache/mongodb-rest-data-panache/deployment/src/main/java/io/quarkus/mongodb/rest/data/panache/deployment/MongoPanacheRestProcessor.java","lineNumber":146,"sourceCode":"                            getEntityFields(index.getIndex(), entityType))));\n            if (capabilities.isPresent(Capability.RESTEASY)) {\n                bytecodeTransformersProducer.produce(\n                        getEntityIdAnnotationTransformer(entityType, entityClassHelper.getIdField(entityType).name()));\n            }\n        }\n    }\n\n    private void validateResource(IndexView index, ClassInfo classInfo) {\n        if (!Modifier.isInterface(classInfo.flags())) {\n            throw new RuntimeException(classInfo.name() + \" has to be an interface\");\n        }\n\n        if (classInfo.interfaceNames().size() > 1) {\n            throw new RuntimeException(classInfo.name() + \" should only extend REST Data Panache interface\");\n        }\n\n        if (!index.getKnownDirectImplementors(classInfo.name()).isEmpty()) {\n            throw new RuntimeException(classInfo.name() + \" should not be extended or implemented\");\n        }\n    }\n\n    private List<Type> getGenericTypes(ClassInfo classInfo) {\n        return classInfo.interfaceTypes()\n                .stream()\n                .findFirst()\n                .orElseThrow(() -> new RuntimeException(classInfo.toString() + \" does not have generic types\"))\n                .asParameterizedType()\n                .arguments();\n    }\n\n    /**\n     * Annotate Mongo entity ID fields with a RESTEasy links annotation.\n     * Otherwise, RESTEasy will not be able to generate links that use ID as path parameter.\n     */\n    private BytecodeTransformerBuildItem getEntityIdAnnotationTransformer(String entityClassName, String idFieldName) {\n        return new BytecodeTransformerBuildItem(entityClassName,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/panache/mongodb-rest-data-panache/deployment/src/main/java/io/quarkus/mongodb/rest/data/panache/deployment/MongoPanacheRestProcessor.java#L128-L164","documentation":"REST Data Panache resource interfaces must be leaves: nothing may extend or implement them. If the Jandex index shows known direct implementors of the resource interface, validateResource throws RuntimeException '<class> should not be extended or implemented'.","triggerScenarios":"Creating a class that implements the resource interface, or a sub-interface extending it, in application code discovered by the build-time index.","commonSituations":"Trying to provide a custom implementation of the generated resource; extending a resource interface to add endpoints; accidentally implementing it in a test/CDI bean that gets indexed.","solutions":["Delete the class extending/implementing the resource interface; customization is done by adding methods to the interface itself (with default implementations calling the repository).","Move custom logic into the repository bean instead of implementing the resource.","Exclude the implementing class from bean discovery/indexing if it is not meant to be a resource."],"exampleFix":"// before\npublic class CustomBookResource implements BookResource { ... } // not allowed\n// after\npublic interface BookResource extends PanacheMongoRepositoryResource<Book, ObjectId> {\n    default List<Book> findByTitle(String title) {\n        return list(\"title\", title); // customize via interface methods\n    }\n}\n","handlingStrategy":"validation","validationCode":"// ensure no class implements the resource\nSet<Class<?>> impls = indexScanner.findImplementors(resource);\nif (!impls.isEmpty()) throw new IllegalArgumentException(\"Resource interfaces must not be implemented: \" + impls);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never implement or extend a REST data resource interface.","Customize resources by adding default methods to the interface.","Put custom logic in the repository bean instead."],"tags":["mongodb","rest-data-panache","build-time","interface-inheritance"],"backgroundTag":"rest-data-resource-extended","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"}