apolloconfig/apollo · error · BadRequestException
Unsupported auth type: %s
Error message
Unsupported auth type: %s
What it means
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.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java:421
|| 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);
}
}
View on GitHub (pinned to d95fc18d11)
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.
Example fix
// before: authType = ANONYMOUS -> 400 client.createNamespace(...); // anonymous, no operator // after: authenticate as CONSUMER with explicit operator client.withConsumerToken(openApiToken).createNamespace(appId, env, cluster, dto, operator="svcacct");
Defensive patterns
Strategy: validation
Validate before calling
// Ensure a recognized auth type before any namespace write.
String authType = UserIdentityContextHolder.getAuthType();
if (!Set.of("USER","USER_TOKEN","CONSUMER").contains(authType)) { /* authenticate */ } Type guard
null
Try / catch
try {
client.createNamespace(appId, env, cluster, dto);
} catch (HttpClientErrorException.BadRequest e) {
if (e.getResponseBodyAsString().contains("Unsupported auth type")) {
// switch to a supported auth mechanism
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unsupported auth type: %s
- Current user not found
- Unsupported auth type: %s
- Current user not found
- Current user not found
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/8a204b79de683fc1.
Report an issue: GitHub.