{"record":{"id":"fa42500979a027bf","repo":"xkcoding/spring-boot-demo","slug":"error-fa4250","errorCode":null,"errorMessage":"不支持的类型","messagePattern":"不支持的类型","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"demo-social/src/main/java/com/xkcoding/social/controller/OauthController.java","lineNumber":81,"sourceCode":"     * 登录成功后的回调\n     *\n     * @param oauthType 第三方登录类型\n     * @param callback  携带返回的信息\n     * @return 登录成功后的信息\n     */\n    @RequestMapping(\"/{oauthType}/callback\")\n    public AuthResponse login(@PathVariable String oauthType, AuthCallback callback) {\n        AuthRequest authRequest = factory.get(getAuthSource(oauthType));\n        AuthResponse response = authRequest.login(callback);\n        log.info(\"【response】= {}\", JSONUtil.toJsonStr(response));\n        return response;\n    }\n\n    private AuthSource getAuthSource(String type) {\n        if (StrUtil.isNotBlank(type)) {\n            return AuthSource.valueOf(type.toUpperCase());\n        } else {\n            throw new RuntimeException(\"不支持的类型\");\n        }\n    }\n}\n","sourceCodeStart":63,"sourceCodeEnd":85,"githubUrl":"https://github.com/xkcoding/spring-boot-demo/blob/87a142f9604c1a5365b4d24d22c2c11c26a9d5ab/demo-social/src/main/java/com/xkcoding/social/controller/OauthController.java#L63-L85","documentation":"OauthController.getAuthSource throws RuntimeException('不支持的类型') only when oauthType is blank; for a non-blank but unknown provider, AuthSource.valueOf(type.toUpperCase()) instead throws IllegalArgumentException that escapes uncaught. The explicit message covers the blank-input case, but the more common unknown-provider path is not handled.","triggerScenarios":"GET /oauth/login/{oauthType} or /{oauthType}/callback with an empty path variable, or with a provider name that is not a constant in the justauth AuthSource enum / not registered in the AuthRequestFactory.","commonSituations":"Hand-edited URLs; a provider disabled in configuration; a typo in the provider name; a justauth version whose AuthSource enum lacks the requested provider.","solutions":["Validate oauthType against factory.oauthList() before calling AuthSource.valueOf","Catch IllegalArgumentException and return HTTP 400 listing the supported providers","Guard the blank case explicitly with a 400 instead of a raw RuntimeException"],"exampleFix":"// before\nprivate AuthSource getAuthSource(String type) {\n    if (StrUtil.isNotBlank(type)) {\n        return AuthSource.valueOf(type.toUpperCase());\n    }\n    throw new RuntimeException('不支持的类型');\n}\n// after\nprivate AuthSource getAuthSource(String type) {\n    if (StrUtil.isBlank(type) || !factory.oauthList().contains(type.toUpperCase())) {\n        throw new IllegalArgumentException('不支持的类型: ' + type);\n    }\n    return AuthSource.valueOf(type.toUpperCase());\n}","handlingStrategy":"validation","validationCode":"List<String> allowed = factory.oauthList();\nString upper = oauthType == null ? '' : oauthType.toUpperCase();\nif (StrUtil.isBlank(oauthType) || !allowed.contains(upper)) {\n    return ResponseEntity.badRequest().body('unsupported type, allowed: ' + allowed);\n}","typeGuard":null,"tryCatchPattern":"try { AuthSource src = getAuthSource(oauthType); }\ncatch (RuntimeException e) { /* '不支持的类型' or IllegalArgumentException */ return ResponseEntity.badRequest().body(e.getMessage()); }","preventionTips":["Whitelist oauthType against factory.oauthList() before AuthSource.valueOf","Treat unknown providers as 400, not 500","Keep the AuthSource enum and justauth version in sync with enabled providers"],"tags":["oauth","justauth","input-validation"],"backgroundTag":null,"analyzedSha":"87a142f9604c1a5365b4d24d22c2c11c26a9d5ab","analyzedAt":"2026-08-14T01:16:58.217Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}