{"record":{"id":"cfff94b55158adb2","repo":"apolloconfig/apollo","slug":"unsupported-auth-type-s","errorCode":null,"errorMessage":"Unsupported auth type: %s","messagePattern":"Unsupported auth type: (.+?)","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java","lineNumber":285,"sourceCode":"        || UserIdentityConstants.USER_TOKEN.equals(authType)) {\n      UserInfo loginUser = userInfoHolder.getUser();\n      if (loginUser == null || !StringUtils.hasText(loginUser.getUserId())) {\n        throw new BadRequestException(\"Current user not found\");\n      }\n      return loginUser.getUserId();\n    }\n\n    if (UserIdentityConstants.CONSUMER.equals(authType)) {\n      if (!StringUtils.hasText(operator)) {\n        throw new BadRequestException(\"operator should not be null or empty\");\n      }\n      if (userService.findByUserId(operator) == null) {\n        throw BadRequestException.userNotExists(operator);\n      }\n      return operator;\n    }\n\n    throw new BadRequestException(\"Unsupported auth type: %s\", authType);\n  }\n\n  private void validatePortalApp(OpenAppDTO app) {\n    if (!UserIdentityConstants.USER.equals(UserIdentityContextHolder.getAuthType())) {\n      return;\n    }\n    if (!StringUtils.hasText(app.getName())) {\n      throw BadRequestException.appNameIsBlank();\n    }\n    if (!InputValidator.isValidClusterNamespace(app.getAppId())) {\n      throw new BadRequestException(\"Invalid AppId format: %s\",\n          InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE);\n    }\n    if (!StringUtils.hasText(app.getOrgId())) {\n      throw BadRequestException.orgIdIsBlank();\n    }\n    if (!StringUtils.hasText(app.getOrgName())) {\n      throw new BadRequestException(\"orgName can not be blank\");","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java#L267-L303","documentation":"Thrown by AppController.resolveOperator when UserIdentityContextHolder.getAuthType() returns a value that is not USER, USER_TOKEN, or CONSUMER. This is a defensive guard indicating an unrecognized or null authentication type in the request context. It should not occur in normal operation — it signals a misconfiguration or a code path that bypasses the standard auth filter. Results in HTTP 400.","triggerScenarios":"A request reaches a controller method that calls resolveOperator, but the auth filter did not set any auth type, or set an unexpected value in UserIdentityContextHolder. This can happen if a new endpoint is exposed without the auth filter, or if a custom auth mechanism sets an unrecognized type.","commonSituations":"A new auth type was introduced in the codebase but resolveOperator was not updated to handle it. The UserIdentityContextHolder thread-local was cleared or never set due to a missing interceptor. A test calls the controller directly without setting up the auth context.","solutions":["Verify the authentication interceptor/filter sets UserIdentityContextHolder with one of the recognized constants (USER, USER_TOKEN, CONSUMER) before the controller executes.","If a new auth type was added, extend resolveOperator to handle it.","For unit tests, set UserIdentityContextHolder.setAuthType(UserIdentityConstants.CONSUMER) before calling the controller."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the auth type is recognized before calling controller methods\nString authType = UserIdentityContextHolder.getAuthType();\nif (!UserIdentityConstants.USER.equals(authType)\n    && !UserIdentityConstants.USER_TOKEN.equals(authType)\n    && !UserIdentityConstants.CONSUMER.equals(authType)) {\n    throw new IllegalStateException(\n        \"Unrecognized or missing auth type: \" + authType + \". Check the auth filter configuration.\");\n}","typeGuard":"public static boolean isRecognizedAuthType(String authType) {\n    return UserIdentityConstants.USER.equals(authType)\n        || UserIdentityConstants.USER_TOKEN.equals(authType)\n        || UserIdentityConstants.CONSUMER.equals(authType);\n}","tryCatchPattern":null,"preventionTips":["Ensure all authenticated endpoints go through the auth filter that sets a recognized auth type.","Add integration tests that verify UserIdentityContextHolder is populated correctly.","If introducing a new auth type, update resolveOperator and all auth-type switches simultaneously."],"tags":["openapi","authentication","apollo-portal","configuration","defensive-guard","auth-type"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}