apolloconfig/apollo · warning · BadRequestException

Unsupported auth type: %s

Error message

Unsupported auth type: %s

What it means

Thrown by ItemController.resolveOperator when the authType from UserIdentityContextHolder does not match USER, USER_TOKEN, or CONSUMER. This is the terminal fallthrough — the method has explicit branches for the three known auth types and throws for anything else (e.g. ANONYMOUS or null). Maps to HTTP 400 BadRequestException.

Source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java:297

        || UserIdentityConstants.USER_TOKEN.equals(authType)) {
      UserInfo loginUser = userInfoHolder.getUser();
      if (loginUser == null || StringUtils.isBlank(loginUser.getUserId())) {
        throw new BadRequestException("Current user not found");
      }
      return loginUser.getUserId();
    }

    if (UserIdentityConstants.CONSUMER.equals(authType)) {
      String operator = StringUtils.isBlank(queryOperator) ? payloadOperator : queryOperator;
      RequestPrecondition.checkArguments(!StringUtils.isContainEmpty(operator),
          "operator should not be null or empty");
      if (userService.findByUserId(operator) == null) {
        throw BadRequestException.userNotExists(operator);
      }
      return operator;
    }

    throw new BadRequestException("Unsupported auth type: %s", authType);
  }

  private boolean shouldHideConfigToPortalUser(String appId, String env, String clusterName,
      String namespaceName) {
    return UserIdentityConstants.USER.equals(UserIdentityContextHolder.getAuthType())
        && unifiedPermissionValidator.shouldHideConfigToCurrentUser(appId, env, clusterName,
            namespaceName);
  }

  private void requireConfigReadForUserToken(String appId, String env, String clusterName,
      String namespaceName) {
    if (UserIdentityConstants.USER_TOKEN.equals(UserIdentityContextHolder.getAuthType())
        && unifiedPermissionValidator.shouldHideConfigToCurrentUser(appId, env, clusterName,
            namespaceName)) {
      throw new AccessDeniedException("Access is denied");
    }
  }

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Ensure the request includes proper authentication and the auth filter sets UserIdentityContextHolder to USER, CONSUMER, or USER_TOKEN.
  2. Check the security filter chain configuration — verify OpenAPI endpoints require authentication and the interceptor populates the auth type.
  3. If a new auth type was introduced, add an explicit branch for it in resolveOperator.
Defensive patterns

Strategy: try-catch

Try / catch

// This error signals a server-side auth pipeline issue — catch and diagnose
try {
    controller.updateItem(appId, env, clusterName, namespaceName, item, false);
} catch (BadRequestException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Unsupported auth type")) {
        logger.error("Auth type not recognized. Security filter may be misconfigured.", e);
        throw new IllegalStateException("Server auth configuration error", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Any item write endpoint where the request reached the controller with an unrecognized or unset authType. This happens when the authentication filter did not populate UserIdentityContextHolder, or set it to ANONYMOUS for a route that requires authenticated access.

Common situations: A misconfigured security filter chain allows unauthenticated requests to reach OpenAPI write endpoints. A custom authentication interceptor fails to call UserIdentityContextHolder.setAuthType(). After an Apollo upgrade, a new auth type constant is introduced but resolveOperator is not updated. Local development with auth filters disabled.

Related errors


AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14). Data as JSON: /api/errors/6f192176559d0fd5. Report an issue: GitHub.