quarkusio/quarkus · error · IllegalArgumentException

Unable to fully read json value

Error message

Unable to fully read json value

What it means

RootResource.approval (GET) throws "Failed to get user principal" when the injected SecurityContext has no principal — getUserPrincipal() returns null and .getName() throws an NPE reported under this error. The endpoint demands an authenticated caller but the request arrived unauthenticated.

Source

Thrown at core/builder/src/main/java/io/quarkus/builder/JsonReader.java:68

        JsonValue result = readValue();
        ignoreWhitespace();
        return result;
    }

    /**
     * value
     * |---- object
     * |---- array
     * |---- string
     * |---- number
     * |---- "true"
     * |---- "false"
     * |---- "null"
     */
    private JsonValue readValue() {
        final int ch = peekChar();
        if (ch < 0) {
            throw new IllegalArgumentException("Unable to fully read json value");
        }

        switch (ch) {
            case '{':
                return readObject();
            case '[':
                return readArray();
            case '"':
                return readString();
            case 't':
                return readConstant("true", JsonBoolean.TRUE);
            case 'f':
                return readConstant("false", JsonBoolean.FALSE);
            case 'n':
                return readConstant("null", JsonNull.INSTANCE);
            default:
                if (Character.isDigit(ch) || '-' == ch) {
                    return readNumber(position);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Send valid authentication credentials with the GET.
  2. Ensure quarkus.http.auth.permission policies require authentication for the path and the elytron realm resolves the user.
  3. Null-check getUserPrincipal() before calling getName().
  4. Confirm quarkus-elytron-security is on the classpath so the SecurityContext is populated.

Example fix

// before
if (sec.getUserPrincipal().getName() == null) {
    throw new RuntimeException("Failed to get user principal");
}
// after
if (sec.getUserPrincipal() == null) {
    throw new RuntimeException("Failed to get user principal");
}
Defensive patterns

Strategy: validation

Validate before calling

if (given().header("tenantId", tenant).get("/fruits/" + id).getStatusCode() == 404) {
    throw new IllegalStateException("Cannot update: fruit " + id + " missing in tenant " + tenant);
}

Try / catch

Response r = given().header("tenantId", tenant).body(fruit).put("/fruits/" + id);
if (r.getStatusCode() == 404) {
    // recreate resource or fail fast with a clear message
}

Prevention

When it happens

Trigger: GET to the resource without credentials, or with credentials the elytron realm rejects, so sec.getUserPrincipal() is null before getName().

Common situations: Anonymous GET allowed by config while test expects auth; wrong username/password; elytron security extension missing so SecurityContext is empty; expired session/token.

Related errors


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