apolloconfig/apollo · warning · BadRequestException

Application's owner not exist.

Error message

Application's owner not exist.

What it means

Thrown by AppService.createAppInLocal when userService.findByUserId(app.getOwnerName()) returns null — the specified app owner is not a known user. BadRequestException → HTTP 400. The owner must exist so its email can be set on the app record.

Source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java:157

    AppDTO appDTO = BeanUtils.transform(AppDTO.class, app);
    appAPI.createApp(env, appDTO);

    roleInitializationService.initClusterNamespaceRoles(app.getAppId(), env.getName(),
        ConfigConsts.CLUSTER_NAME_DEFAULT, operator);
  }

  private App createAppInLocal(App app, String operator) {
    validateOperator(operator);
    String appId = app.getAppId();
    App managedApp = appRepository.findByAppId(appId);

    if (managedApp != null) {
      throw BadRequestException.appAlreadyExists(appId);
    }

    UserInfo owner = userService.findByUserId(app.getOwnerName());
    if (owner == null) {
      throw new BadRequestException("Application's owner not exist.");
    }
    app.setOwnerEmail(owner.getEmail());

    app.setDataChangeCreatedBy(operator);
    app.setDataChangeLastModifiedBy(operator);

    App createdApp = appRepository.save(app);

    appNamespaceService.createDefaultAppNamespace(appId, operator);
    roleInitializationService.initAppRoles(createdApp);
    List<Env> envs = portalSettings.getActiveEnvs();
    for (Env env : envs) {
      roleInitializationService.initClusterNamespaceRoles(appId, env.getName(),
          ConfigConsts.CLUSTER_NAME_DEFAULT, operator);
    }

    Tracer.logEvent(TracerEventType.CREATE_APP, appId);

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Confirm the ownerName is a real, provisioned user via userService.findByUserId before creating the app.
  2. Provision/sync the owner account into the portal user store first.
  3. Use the exact userId (case-sensitive) as stored.

Example fix

// before
app.setOwnerName("alic"); // typo
appService.createAppInLocal(app, operator);

// after
if (userService.findByUserId(app.getOwnerName()) == null) {
  throw new IllegalArgumentException("owner " + app.getOwnerName() + " is not a known user");
}
appService.createAppInLocal(app, operator);
Defensive patterns

Strategy: validation

Validate before calling

if (userService.findByUserId(app.getOwnerName()) == null) {
  return ResponseEntity.badRequest().body("owner does not exist: " + app.getOwnerName());
}

Type guard

boolean isKnownOwner(String ownerName, UserService svc) { return svc.findByUserId(ownerName) != null; }

Prevention

When it happens

Trigger: Creating an app whose ownerName does not resolve to a UserInfo (mistyped userId, user not yet provisioned, wrong directory).

Common situations: Owner userId typo; owner exists in LDAP but not yet synced into the portal UserService; cross-environment owner reference that doesn't exist locally; copying an app spec from another org.

Related errors


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