{"record":{"id":"0858af3f685f7dab","repo":"apolloconfig/apollo","slug":"current-user-not-found-0858af","errorCode":null,"errorMessage":"Current user not found","messagePattern":"Current user not found","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java","lineNumber":406,"sourceCode":"    }\n  }\n\n  private void requireDeleteNamespacePermissionForUserToken(String appId, String env,\n      String clusterName, String namespaceName) {\n    if (UserIdentityConstants.USER_TOKEN.equals(UserIdentityContextHolder.getAuthType())\n        && !unifiedPermissionValidator.hasDeleteNamespacePermission(appId, env, clusterName,\n            namespaceName)) {\n      throw new AccessDeniedException(\"Delete namespace permission is required\");\n    }\n  }\n\n  private String resolveOperator(String queryOperator, String payloadOperator) {\n    String authType = UserIdentityContextHolder.getAuthType();\n    if (UserIdentityConstants.USER.equals(authType)\n        || 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":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java#L388-L424","documentation":"HTTP 400 (BadRequestException). Thrown by NamespaceController.resolveOperator: auth type USER or USER_TOKEN but UserInfoHolder.getUser() returns null or a UserInfo with a blank userId. The operator cannot be derived because the authenticated principal was not populated. Same root cause as error 84, on the NamespaceController surface.","triggerScenarios":"Any NamespaceController mutating API (create/update/delete namespace) authenticated as USER/USER_TOKEN where the security principal is missing or has a blank userId at controller time.","commonSituations":"Portal SSO session expired mid-request; user-token authenticated but did not resolve to a UserInfo; custom auth filter sets authType=USER without populating UserInfoHolder; gateway stripped auth headers.","solutions":["Re-authenticate to obtain a fresh session/user-token and retry.","Fix the auth integration so UserInfoHolder is populated with a non-blank userId for USER/USER_TOKEN.","Authenticate as CONSUMER and pass an explicit operator if using OpenAPI.","Verify security filter ordering places principal population before the controller."],"exampleFix":"// before: USER auth but principal missing\nUserInfo u = userInfoHolder.getUser(); // null -> 400\n\n// after: auth filter sets principal, or switch auth type\nclient.withConsumerToken(openApiToken).createNamespace(appId, env, cluster, dto, operator=\"svcacct\");","handlingStrategy":"try-catch","validationCode":"// For USER/USER_TOKEN: ensure principal exists before any namespace write.\nUserInfo u = userInfoHolder.getUser();\nif (u == null || StringUtils.isBlank(u.getUserId())) { /* re-authenticate */ }","typeGuard":"null","tryCatchPattern":"try {\n  client.createNamespace(appId, env, cluster, dto);\n} catch (HttpClientErrorException.BadRequest e) {\n  if (e.getResponseBodyAsString().contains(\"Current user not found\")) {\n    refreshToken(); client.createNamespace(appId, env, cluster, dto);\n  }\n}","preventionTips":["Refresh sessions/tokens before expiry.","Ensure the auth filter populates UserInfoHolder.","Use CONSUMER auth with an explicit operator for headless work."],"tags":["apollo-portal","openapi","auth","bad-request","operator","user","namespace"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}