apolloconfig/apollo · error · BadRequestException

orgName can not be blank

Error message

orgName can not be blank

What it means

Thrown by AppController.validatePortalApp when the auth type is USER and app.getOrgName() is blank (null, empty, or whitespace-only). For Portal UI users, Apollo requires an organization name as part of app metadata. This validation only applies to USER auth type — CONSUMER and USER_TOKEN skip it. Results in HTTP 400.

Source

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

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

  private void validatePortalApp(OpenAppDTO app) {
    if (!UserIdentityConstants.USER.equals(UserIdentityContextHolder.getAuthType())) {
      return;
    }
    if (!StringUtils.hasText(app.getName())) {
      throw BadRequestException.appNameIsBlank();
    }
    if (!InputValidator.isValidClusterNamespace(app.getAppId())) {
      throw new BadRequestException("Invalid AppId format: %s",
          InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE);
    }
    if (!StringUtils.hasText(app.getOrgId())) {
      throw BadRequestException.orgIdIsBlank();
    }
    if (!StringUtils.hasText(app.getOrgName())) {
      throw new BadRequestException("orgName can not be blank");
    }
    if (!StringUtils.hasText(app.getOwnerName())) {
      throw BadRequestException.ownerNameIsBlank();
    }
  }

  private Set<String> findAppIdsAuthorizedByCurrentIdentity() {
    if (UserIdentityConstants.USER.equals(UserIdentityContextHolder.getAuthType())) {
      UserInfo loginUser = userInfoHolder.getUser();
      if (loginUser == null || !StringUtils.hasText(loginUser.getUserId())) {
        return Collections.emptySet();
      }
      Set<String> appIds = new LinkedHashSet<>();
      List<Role> userRoles = rolePermissionService.findUserRoles(loginUser.getUserId());
      if (userRoles == null) {
        return appIds;
      }
      for (Role role : userRoles) {

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Provide a non-blank orgName in the app object (e.g., 'Engineering', 'Finance').
  2. Ensure the Portal UI form requires orgName before submission (client-side validation).
  3. If creating apps via API with a USER token, always set orgName explicitly.

Example fix

// before
app.setOrgName("");

// after
app.setOrgName("Engineering");
Defensive patterns

Strategy: validation

Validate before calling

// Validate orgName is present before app creation (USER auth)
if (!StringUtils.hasText(app.getOrgName())) {
    throw new IllegalArgumentException("orgName must not be blank");
}

Type guard

public static boolean hasValidOrgName(OpenAppDTO app) {
    return app != null && StringUtils.hasText(app.getOrgName());
}

Prevention

When it happens

Trigger: Creating or updating an app via the Portal UI (USER auth type) where the orgName field is left empty. The OpenAppDTO has all other fields populated but orgName is null or "".

Common situations: A user in the Portal UI does not select or type an organization name. A client submits the form with orgName omitted. The org name field was cleared or defaulted to empty in the UI.

Related errors


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