{"record":{"id":"8a204b79de683fc1","repo":"apolloconfig/apollo","slug":"unsupported-auth-type-s-8a204b","errorCode":null,"errorMessage":"Unsupported auth type: %s","messagePattern":"Unsupported auth type: (.+?)","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java","lineNumber":421,"sourceCode":"        || UserIdentityConstants.USER_TOKEN.equals(authType)) {\n      UserInfo loginUser = userInfoHolder.getUser();\n      if (loginUser == null || StringUtils.isBlank(loginUser.getUserId())) {\n        throw new BadRequestException(\"Current user not found\");\n      }\n      return loginUser.getUserId();\n    }\n\n    if (UserIdentityConstants.CONSUMER.equals(authType)) {\n      String operator = StringUtils.isBlank(queryOperator) ? payloadOperator : queryOperator;\n      RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(operator),\n          \"operator should not be null or empty\");\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","sourceCodeStart":403,"sourceCodeEnd":424,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java#L403-L424","documentation":"HTTP 400 (BadRequestException). Thrown by NamespaceController.resolveOperator when UserIdentityContextHolder.getAuthType() is not USER, USER_TOKEN, or CONSUMER (e.g. ANONYMOUS or null/unrecognized). The controller cannot derive the operator without a recognized auth type. Same root cause as error 85, on the NamespaceController surface.","triggerScenarios":"Any NamespaceController mutating API call where the request authenticated as ANONYMOUS or where authType was never set in the context and still reached the controller.","commonSituations":"Endpoint accidentally permitting anonymous access; security filter failed to set authType; new auth scheme without a registered constant; unit/integration tests hitting the bean with no security context.","solutions":["Authenticate with a supported mechanism (portal SSO -> USER, user-token -> USER_TOKEN, OpenAPI token -> CONSUMER).","Fix the security filter to populate UserIdentityContextHolder.authType for every authenticated request.","Reject anonymous requests before the controller; resolveOperator has no anonymous fallback.","Ensure the auth-type string matches 'USER'/'USER_TOKEN'/'CONSUMER' exactly."],"exampleFix":"// before: authType = ANONYMOUS -> 400\nclient.createNamespace(...); // anonymous, no operator\n\n// after: authenticate as CONSUMER with explicit operator\nclient.withConsumerToken(openApiToken).createNamespace(appId, env, cluster, dto, operator=\"svcacct\");","handlingStrategy":"validation","validationCode":"// Ensure a recognized auth type before any namespace write.\nString authType = UserIdentityContextHolder.getAuthType();\nif (!Set.of(\"USER\",\"USER_TOKEN\",\"CONSUMER\").contains(authType)) { /* authenticate */ }","typeGuard":"null","tryCatchPattern":"try {\n  client.createNamespace(appId, env, cluster, dto);\n} catch (HttpClientErrorException.BadRequest e) {\n  if (e.getResponseBodyAsString().contains(\"Unsupported auth type\")) {\n    // switch to a supported auth mechanism\n  }\n}","preventionTips":["Authenticate mutating requests as USER, USER_TOKEN, or CONSUMER.","Reject anonymous requests in the security filter.","Register any new auth scheme's constant before use."],"tags":["apollo-portal","openapi","auth","bad-request","operator","anonymous","namespace"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}