{"record":{"id":"1f5743c33ad323be","repo":"jwtk/jjwt","slug":"cannot-decode-input-string-cause-e-getmessage","errorCode":null,"errorMessage":"Cannot decode input String. Cause: ${e.getMessage()}","messagePattern":"Cannot decode input String\\. Cause: (.+?)","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/src/main/java/io/jsonwebtoken/impl/io/Codec.java","lineNumber":50,"sourceCode":"    private final Decoder<CharSequence, byte[]> decoder;\n\n    public Codec(Encoder<byte[], String> encoder, Decoder<CharSequence, byte[]> decoder) {\n        this.encoder = Assert.notNull(encoder, \"Encoder cannot be null.\");\n        this.decoder = Assert.notNull(decoder, \"Decoder cannot be null.\");\n    }\n\n    @Override\n    public String applyTo(byte[] a) {\n        return this.encoder.encode(a);\n    }\n\n    @Override\n    public byte[] applyFrom(CharSequence b) {\n        try {\n            return this.decoder.decode(b);\n        } catch (DecodingException e) {\n            String msg = \"Cannot decode input String. Cause: \" + e.getMessage();\n            throw new IllegalArgumentException(msg, e);\n        }\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":54,"githubUrl":"https://github.com/jwtk/jjwt/blob/fb71496164c71442d08adec4571d9616ed5e1b8d/impl/src/main/java/io/jsonwebtoken/impl/io/Codec.java#L32-L54","documentation":"Thrown by Codec.applyFrom when the configured Decoder rejects the input CharSequence — the string is not valid for the codec's encoding (e.g. malformed Base64/Base64URL when decoding a compact JWT/JWK segment). The DecodingException's message is wrapped as the cause; this is a data-format failure of the supplied text, not a configuration problem.","triggerScenarios":"Thrown at impl/src/main/java/io/jsonwebtoken/impl/io/Codec.java:50 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the cause message to identify the exact encoding defect (illegal character, bad padding, strict-decoding violation)","Verify the input string is complete and unmodified — no truncation, whitespace, or URL-safety mixing (use Base64URL for JWT segments)","Re-obtain or re-encode the value from the source; do not attempt to 'repair' encoded payloads by hand"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}