{"record":{"id":"00d26dbf654c88d0","repo":"quarkusio/quarkus","slug":"failed-to-get-user-principal-00d26d","errorCode":null,"errorMessage":"Failed to get user principal","messagePattern":"Failed to get user principal","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"integration-tests/elytron-undertow/src/main/java/io/quarkus/it/undertow/elytron/RootResource.java","lineNumber":22,"sourceCode":"import jakarta.ws.rs.GET;\nimport jakarta.ws.rs.POST;\nimport jakarta.ws.rs.Path;\nimport jakarta.ws.rs.Produces;\nimport jakarta.ws.rs.core.Context;\nimport jakarta.ws.rs.core.MediaType;\nimport jakarta.ws.rs.core.SecurityContext;\n\n@Path(\"/rest\")\npublic class RootResource {\n\n    @POST\n    @Consumes(MediaType.TEXT_PLAIN)\n    public String posts(String data, @Context SecurityContext sec) {\n        if (data == null) {\n            throw new RuntimeException(\"No post data\");\n        }\n        if (sec.getUserPrincipal().getName() == null) {\n            throw new RuntimeException(\"Failed to get user principal\");\n        }\n        return \"post success\";\n    }\n\n    @GET\n    @Produces(MediaType.TEXT_PLAIN)\n    public String approval(@Context SecurityContext sec) {\n        if (sec.getUserPrincipal().getName() == null) {\n            throw new RuntimeException(\"Failed to get user principal\");\n        }\n        return \"get success\";\n    }\n}\n","sourceCodeStart":4,"sourceCodeEnd":36,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/elytron-undertow/src/main/java/io/quarkus/it/undertow/elytron/RootResource.java#L4-L36","documentation":"Sentinel guard in an elytron-undertow integration-test JAX-RS resource: SecurityContext.getUserPrincipal() (or its name) is null on an endpoint the test expects to be authenticated. Test-application validation of the injected SecurityContext.","triggerScenarios":"Thrown at integration-tests/elytron-undertow/src/main/java/io/quarkus/it/undertow/elytron/RootResource.java:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Authenticate the request (the test client must send credentials)","Verify the REST endpoint is covered by the security policy"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}