quarkusio/quarkus · error · RuntimeException

Failed to get user principal

Error message

Failed to get user principal

What it means

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.

Source

Thrown at integration-tests/elytron-undertow/src/main/java/io/quarkus/it/undertow/elytron/RootResource.java:22

import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.SecurityContext;

@Path("/rest")
public class RootResource {

    @POST
    @Consumes(MediaType.TEXT_PLAIN)
    public String posts(String data, @Context SecurityContext sec) {
        if (data == null) {
            throw new RuntimeException("No post data");
        }
        if (sec.getUserPrincipal().getName() == null) {
            throw new RuntimeException("Failed to get user principal");
        }
        return "post success";
    }

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String approval(@Context SecurityContext sec) {
        if (sec.getUserPrincipal().getName() == null) {
            throw new RuntimeException("Failed to get user principal");
        }
        return "get success";
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Authenticate the request (the test client must send credentials)
  2. Verify the REST endpoint is covered by the security policy
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at integration-tests/elytron-undertow/src/main/java/io/quarkus/it/undertow/elytron/RootResource.java:22 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/00d26dbf654c88d0. Report an issue: GitHub.