{"record":{"id":"be5247fee2722a13","repo":"quarkusio/quarkus","slug":"a-synthetic-bean-bean-was-defined-with-invalid","errorCode":null,"errorMessage":"A synthetic bean ${bean} was defined with invalid scope annotation - ${scopeName}. Please use one of the built-in scopes or a valid, registered custom scope.","messagePattern":"A synthetic bean (.+?) was defined with invalid scope annotation - (.+?)\\. Please use one of the built-in scopes or a valid, registered custom scope\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java","lineNumber":1034,"sourceCode":"                                \"%s is not proxyable because it has a private no-args constructor: %s.\", classifier, bean)));\n                    } else {\n                        bean.getDeployment().deferUnproxyableErrorToRuntime(bean);\n                    }\n                }\n            }\n            if (returnTypeClass != null && bean.getScope().isNormal() && returnTypeClass.isSealed()) {\n                if (failIfNotProxyable) {\n                    errors.add(new DeploymentException(\n                            String.format(\"%s must not have a return type that is sealed: %s\", classifier, bean)));\n                } else {\n                    bean.getDeployment().deferUnproxyableErrorToRuntime(bean);\n                }\n            }\n        } else if (bean.isSynthetic()) {\n            // synth beans can accidentally be defined with a non-existing scope, throw exception in such case\n            DotName scopeName = bean.getScope().getDotName();\n            if (bean.getDeployment().getScope(scopeName) == null) {\n                throw new IllegalArgumentException(\"A synthetic bean \" + bean + \" was defined with invalid scope annotation - \"\n                        + scopeName + \". Please use one of the built-in scopes or a valid, registered custom scope.\");\n            }\n            // this is for synthetic beans that need to be proxied but their classes don't have no-args constructor\n            ClassInfo beanClass = getClassByName(bean.getDeployment().getBeanArchiveIndex(), bean.getBeanClass());\n            MethodInfo noArgsConstructor = beanClass.method(Methods.INIT);\n            if (bean.getScope().isNormal() && !Modifier.isInterface(beanClass.flags()) && noArgsConstructor == null) {\n                if (bean.getDeployment().transformUnproxyableClasses) {\n                    DotName superName = beanClass.superName();\n                    if (!DotNames.OBJECT.equals(superName)) {\n                        ClassInfo superClass = bean.getDeployment().getBeanArchiveIndex().getClassByName(beanClass.superName());\n                        if (superClass == null || !superClass.hasNoArgsConstructor()) {\n                            // Bean class extends a class without no-args constructor\n                            // It is not possible to generate a no-args constructor reliably\n                            superName = null;\n                        }\n                    }\n                    if (superName != null) {\n                        if (!classesReceivingNoArgsCtor.contains(beanClass.name())) {","sourceCodeStart":1016,"sourceCodeEnd":1052,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Beans.java#L1016-L1052","documentation":"Synthetic beans (registered programmatically via SyntheticBeanBuilder) may accidentally reference a scope annotation that was never registered in the deployment. Because synthetic beans bypass class-level validation, ArC validates the scope at generation time and throws IllegalArgumentException when the scope is unknown.","triggerScenarios":"Beans (public validation block) processes a bean where bean.isSynthetic() and bean.getDeployment().getScope(scopeName) == null — the scope annotation on the synthetic bean has no corresponding registered scope in the BeanDeployment.","commonSituations":"Registering a synthetic bean with a custom scope annotation that lacks @Scope/meta-annotation registration or an extension that did not register the scope; typo in the scope class passed to SyntheticBeanBuilder; missing quarkus.arc component for a custom scope.","solutions":["Use a built-in scope (@Dependent, @ApplicationScoped, @Singleton, @RequestScoped) when registering the synthetic bean","Register the custom scope in your extension so BeanDeployment knows it (and add a runtime scope annotation/meta-annotation)","Fix the scope class reference (typo/wrong import) in the SyntheticBeanBuilder call"],"exampleFix":"// before\nsyntheticBean.addScope(MyUnregisteredScope.class);\n// after\nsyntheticBean.addScope(ApplicationScoped.class); // or register the custom scope in the extension","handlingStrategy":"validation","validationCode":"// in an extension registering a synthetic bean\nDotName scopeName = DotName.createSimple(scopeCls.getName());\nif (deployment.getScope(scopeName) == null) {\n    throw new IllegalStateException(\"Scope not registered for synthetic bean: \" + scopeName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    syntheticBeans.register(...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"invalid scope annotation\")) {\n        logger.errorf(\"Use a registered scope for synthetic bean: %s\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Register custom scopes in the extension before using them on synthetic beans","Default to built-in scopes for synthetic beans","Double-check imports for scope annotation classes"],"tags":["cdi","arc","synthetic-bean","scopes"],"backgroundTag":"unregistered-scope-annotation","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"}