{"record":{"id":"66998113d8a2ffc2","repo":"cryptomator/cryptomator","slug":"failed-to-parse-jwe","errorCode":null,"errorMessage":"Failed to parse JWE","messagePattern":"Failed to parse JWE","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/cryptomator/ui/keyloading/hub/ReceiveKeyController.java","lineNumber":297,"sourceCode":"\t\t\t\tcase 402 -> licenseExceeded();\n\t\t\t\tcase 403 -> accessNotGranted();\n\t\t\t\tcase 410 -> accessGoneVaultArchived();\n\t\t\t\tcase 404 -> needsLegacyDeviceRegistration();\n\t\t\t\tdefault -> throw new IOException(\"Unexpected response \" + response.statusCode());\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\tthrow new UncheckedIOException(e);\n\t\t}\n\t}\n\n\t@Deprecated\n\tprivate void receivedLegacyAccessTokenSuccess(String rawToken) throws IOException {\n\t\ttry {\n\t\t\tvar token = JWEObject.parse(rawToken);\n\t\t\tresult.complete(ReceivedKey.legacyDeviceKey(token));\n\t\t\twindow.close();\n\t\t} catch (ParseException e) {\n\t\t\tthrow new IOException(\"Failed to parse JWE\", e);\n\t\t}\n\t}\n\n\tprivate void licenseExceeded() {\n\t\twindow.setScene(invalidLicenseScene.get());\n\t}\n\n\t@Deprecated\n\tprivate void needsLegacyDeviceRegistration() {\n\t\twindow.setScene(legacyRegisterDeviceScene.get());\n\t}\n\n\tprivate void accessNotGranted() {\n\t\twindow.setScene(unauthorizedScene.get());\n\t}\n\n\tprivate void accessGoneVaultArchived() {\n\t\twindow.close();","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/cryptomator/cryptomator/blob/af99135172ecacf49658db7a4686fc5cf2102817/src/main/java/org/cryptomator/ui/keyloading/hub/ReceiveKeyController.java#L279-L315","documentation":"ReceiveKeyController.receivedLegacyAccessTokenSuccess parses a raw legacy access token as a JWEObject; a ParseException (token not valid compact JWE serialization) is rethrown as IOException(\"Failed to parse JWE\"). The token delivered by the legacy Hub flow could not be structurally parsed.","triggerScenarios":"The legacy access token string handed to receivedLegacyAccessTokenSuccess (via receivedLegacyAccessTokenResponse) is empty, HTML (e.g. an error page), truncated, or otherwise not in JWE compact serialization, causing JWEObject.parse to throw ParseException.","commonSituations":"Hub server returning an error page instead of the token, legacy flow interrupted producing partial token, copy/paste or clipboard corruption of the token, Hub version emitting a plain JWT where a JWE is expected.","solutions":["Log/inspect the raw token's first characters — it should start with five dot-separated Base64URL segments","Verify the Hub server actually supports the legacy token flow being used; upgrade client or server to matching versions","Retry the key-receive flow to get a fresh token","Check for proxies/URL handlers mangling the token before it reaches the controller"],"exampleFix":"// before\ncatch (ParseException e) { throw new IOException(\"Failed to parse JWE\", e); }\n// after: fail with diagnostics\ncatch (ParseException e) {\n    LOG.error(\"token not JWE: {}...\", rawToken.substring(0, Math.min(20, rawToken.length())));\n    throw new IOException(\"Failed to parse JWE\", e);\n}","handlingStrategy":"validation","validationCode":"static boolean looksLikeJwe(String token) {\n    return token != null && token.chars().filter(c -> c == '.').count() == 4;\n}","typeGuard":"static boolean isParseableJwe(String raw) { try { JWEObject.parse(raw); return true; } catch (ParseException e) { return false; } }","tryCatchPattern":"try { receivedLegacyAccessTokenSuccess(rawToken); } catch (IOException e) { showInvalidTokenScene(); LOG.error(\"token not JWE\", e.getCause()); }","preventionTips":["Check token shape (5 dot-separated segments) before parsing","Retry the flow to obtain a fresh token on parse failure","Ensure the Hub server's legacy flow is enabled and version-compatible"],"tags":["jwe","parsing","hub","legacy"],"backgroundTag":"jwe-parse-failed","analyzedSha":"af99135172ecacf49658db7a4686fc5cf2102817","analyzedAt":"2026-09-05T09:14:34.887Z","contentChangedAt":"2026-09-05T09:14:34.887Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}