{"record":{"id":"8928f42f47ba897d","repo":"apolloconfig/apollo","slug":"application-s-owner-not-exist","errorCode":null,"errorMessage":"Application's owner not exist.","messagePattern":"Application's owner not exist\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java","lineNumber":157,"sourceCode":"    AppDTO appDTO = BeanUtils.transform(AppDTO.class, app);\n    appAPI.createApp(env, appDTO);\n\n    roleInitializationService.initClusterNamespaceRoles(app.getAppId(), env.getName(),\n        ConfigConsts.CLUSTER_NAME_DEFAULT, operator);\n  }\n\n  private App createAppInLocal(App app, String operator) {\n    validateOperator(operator);\n    String appId = app.getAppId();\n    App managedApp = appRepository.findByAppId(appId);\n\n    if (managedApp != null) {\n      throw BadRequestException.appAlreadyExists(appId);\n    }\n\n    UserInfo owner = userService.findByUserId(app.getOwnerName());\n    if (owner == null) {\n      throw new BadRequestException(\"Application's owner not exist.\");\n    }\n    app.setOwnerEmail(owner.getEmail());\n\n    app.setDataChangeCreatedBy(operator);\n    app.setDataChangeLastModifiedBy(operator);\n\n    App createdApp = appRepository.save(app);\n\n    appNamespaceService.createDefaultAppNamespace(appId, operator);\n    roleInitializationService.initAppRoles(createdApp);\n    List<Env> envs = portalSettings.getActiveEnvs();\n    for (Env env : envs) {\n      roleInitializationService.initClusterNamespaceRoles(appId, env.getName(),\n          ConfigConsts.CLUSTER_NAME_DEFAULT, operator);\n    }\n\n    Tracer.logEvent(TracerEventType.CREATE_APP, appId);\n","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java#L139-L175","documentation":"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.","triggerScenarios":"Creating an app whose ownerName does not resolve to a UserInfo (mistyped userId, user not yet provisioned, wrong directory).","commonSituations":"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.","solutions":["Confirm the ownerName is a real, provisioned user via userService.findByUserId before creating the app.","Provision/sync the owner account into the portal user store first.","Use the exact userId (case-sensitive) as stored."],"exampleFix":"// before\napp.setOwnerName(\"alic\"); // typo\nappService.createAppInLocal(app, operator);\n\n// after\nif (userService.findByUserId(app.getOwnerName()) == null) {\n  throw new IllegalArgumentException(\"owner \" + app.getOwnerName() + \" is not a known user\");\n}\nappService.createAppInLocal(app, operator);","handlingStrategy":"validation","validationCode":"if (userService.findByUserId(app.getOwnerName()) == null) {\n  return ResponseEntity.badRequest().body(\"owner does not exist: \" + app.getOwnerName());\n}","typeGuard":"boolean isKnownOwner(String ownerName, UserService svc) { return svc.findByUserId(ownerName) != null; }","tryCatchPattern":null,"preventionTips":["Verify the owner userId exists in the user store before app creation.","Sync users from LDAP/IdP before referencing them as owners."],"tags":["apollo-portal","app-service","validation","owner"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}