{"record":{"id":"bd81cfbe3c720494","repo":"jwtk/jjwt","slug":"value-must-be-a-map-string-json-object-type","errorCode":null,"errorMessage":"Value must be a Map<String,?> (JSON Object). Type found: ${type}.","messagePattern":"Value must be a Map<String,\\?> \\(JSON Object\\)\\. Type found: (.+?)\\.","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/src/main/java/io/jsonwebtoken/impl/security/JwkSetConverter.java","lineNumber":79,"sourceCode":"\n    public boolean isIgnoreUnsupported() {\n        return ignoreUnsupported;\n    }\n\n    @Override\n    public Object applyTo(JwkSet jwkSet) {\n        return jwkSet;\n    }\n\n    @Override\n    public JwkSet applyFrom(Object o) {\n        Assert.notNull(o, \"Value cannot be null.\");\n        if (o instanceof JwkSet) {\n            return (JwkSet) o;\n        }\n        if (!(o instanceof Map)) {\n            String msg = \"Value must be a Map<String,?> (JSON Object). Type found: \" + o.getClass().getName() + \".\";\n            throw new IllegalArgumentException(msg);\n        }\n        final Map<?, ?> m = Collections.immutable((Map<?, ?>) o);\n\n        // mandatory for all JWK Sets: https://datatracker.ietf.org/doc/html/rfc7517#section-5\n        // no need for builder parameter type conversion overhead if this isn't present:\n        if (Collections.isEmpty(m) || !m.containsKey(PARAM.getId())) {\n            String msg = \"Missing required \" + PARAM + \" parameter.\";\n            throw new MalformedKeySetException(msg);\n        }\n        Object val = m.get(PARAM.getId());\n        if (val == null) {\n            String msg = \"JWK Set \" + PARAM + \" value cannot be null.\";\n            throw new MalformedKeySetException(msg);\n        }\n        if (!(val instanceof Collection)) {\n            String msg = \"JWK Set \" + PARAM + \" value must be a Collection (JSON Array). Type found: \" +\n                    val.getClass().getName();\n            throw new MalformedKeySetException(msg);","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/impl/src/main/java/io/jsonwebtoken/impl/security/JwkSetConverter.java#L61-L97","documentation":"JwkSetConverter.applyFrom requires its input to be a Map (JSON Object) representing a JWK Set, or an existing JwkSet. If the value is neither, IllegalArgumentException is thrown naming the actual type found.","triggerScenarios":"Passing a String, List, InputStream, or other non-Map object directly to JWK Set conversion (e.g. passing a parsed 'keys' array instead of the wrapping object).","commonSituations":"Passing the raw JWKS 'keys' array instead of the full {\"keys\":[...]} document; passing unparsed JSON text instead of a parsed Map.","solutions":["Pass the full JWKS document as a Map: {\"keys\":[...]} (parse the JSON string first if needed)","If you have a List of keys, wrap it: Map.of(\"keys\", keyList)","Use the appropriate Jwks parser API that accepts raw JSON text rather than pre-conversion"],"exampleFix":"// before\njwkSetConverter.applyFrom(keysArray); // List, not Map\n// after\njwkSetConverter.applyFrom(Map.of(\"keys\", keysArray));","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof Map)) { throw new IllegalArgumentException(\"JWK Set input must be a Map\"); }","typeGuard":"boolean isJwkSetShape(Object o) { return o instanceof JwkSet || (o instanceof Map<?,?> m && m.containsKey(\"keys\")); }","tryCatchPattern":"try { JwkSet set = jwkSetConverter.applyFrom(obj); } catch (IllegalArgumentException e) { log.error(\"Not a JWK Set object: {}\", e.getMessage()); }","preventionTips":["Parse JSON text into a Map before JWK Set conversion","Pass the full {\"keys\":[...]} document, not the inner array"],"tags":["jwt","jwks","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"fb71496164c71442d08adec4571d9616ed5e1b8d","analyzedAt":"2026-09-09T00:33:09.982Z","contentChangedAt":"2026-09-09T00:33:09.982Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}