{"record":{"id":"4ffc42bcc682cc52","repo":"quarkusio/quarkus","slug":"unsupported-roles-field-getter-type-rolestype","errorCode":null,"errorMessage":"Unsupported @Roles field/getter type: ${rolesType}","messagePattern":"Unsupported @Roles field/getter type: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/security-jpa-common/deployment/src/main/java/io/quarkus/security/jpa/common/deployment/JpaSecurityIdentityUtil.java","lineNumber":206,"sourceCode":"                    // }\n                    bc.forEach(role, (loopBody, var) -> {\n                        Expr roleElement;\n                        if (rolesFieldOrMethod != null) {\n                            roleElement = rolesFieldOrMethod.readValue(loopBody, var);\n                        } else {\n                            roleElement = var;\n                        }\n                        loopBody.invokeStatic(\n                                MethodDesc.of(JpaIdentityProviderUtil.class, \"addRoles\", void.class,\n                                        QuarkusSecurityIdentity.Builder.class, String.class),\n                                builderVar, roleElement);\n                    });\n                    handledRole = true;\n                }\n                break;\n        }\n        if (!handledRole) {\n            throw new RuntimeException(\"Unsupported @Roles field/getter type: \" + rolesType);\n        }\n\n        // return builder.build()\n        bc.return_(bc.invokeVirtual(\n                MethodDesc.of(QuarkusSecurityIdentity.Builder.class,\n                        \"build\",\n                        QuarkusSecurityIdentity.class),\n                builderVar));\n    }\n\n    private static MethodDesc getUtilMethod(String passwordProviderMethod) {\n        return MethodDesc.of(JpaIdentityProviderUtil.class, passwordProviderMethod,\n                Password.class, String.class);\n    }\n\n    private static MethodDesc passwordActionMethod() {\n        return MethodDesc.of(JpaIdentityProviderUtil.class, \"passwordAction\", void.class, PasswordType.class);\n    }","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/security-jpa-common/deployment/src/main/java/io/quarkus/security/jpa/common/deployment/JpaSecurityIdentityUtil.java#L188-L224","documentation":"The @Roles field/getter type must be String, List<X>, Collection<X>, or Set<X>. Arrays and any other type kind (primitive, other classes, wildcard types, etc.) are not supported by the build-time role handler, so the build fails.","triggerScenarios":"Annotating a field/getter with @Roles whose declared type is String[], an array of entities, a Map, a raw/non-parameterized generic type (whose kind is CLASS but not String), or any other unsupported type.","commonSituations":"Using String[] roles from legacy code; using a raw List without type parameters (element type unknown -> handledRole stays false); using Optional<List<String>> or custom collection types not in the supported trio.","solutions":["Change the @Roles field/getter type to String, List<String>, Set<String>, or Collection<String>.","If roles are entities, use List<RoleEntity>/Set<RoleEntity> with a @RoleValue on the role class.","If using a generic collection, always supply type parameters (e.g. List<String>, not raw List).","Convert arrays (String[]) to List via entity mapping or change the JPA mapping to @ElementCollection."],"exampleFix":"// before\n@Roles\npublic String[] roles;\n\n// after\n@Roles\n@ElementCollection\npublic List<String> roles;","handlingStrategy":"validation","validationCode":"Class<?> t = rolesField.getType();\nboolean ok = t == String.class || List.class.isAssignableFrom(t)\n        || Set.class.isAssignableFrom(t) || Collection.class.isAssignableFrom(t);\nif (!ok) throw new IllegalStateException(\"@Roles must be String or List/Set/Collection\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use String, List<String>, Set<String>, or Collection<String> for @Roles.","Never use arrays or raw generics for the roles field.","Use @ElementCollection for entity-backed role collections."],"tags":["quarkus","security-jpa","build-time","unsupported-type"],"backgroundTag":"unsupported-field-type","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"}