{"record":{"id":"0d2faa52dfdeb207","repo":"apolloconfig/apollo","slug":"app-s-owner-not-exists-owner-s","errorCode":null,"errorMessage":"App's owner not exists. owner = %s","messagePattern":"App's owner not exists\\. owner = (.+?)","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java","lineNumber":231,"sourceCode":"  @Transactional\n  @ApolloAuditLog(type = OpType.UPDATE, name = \"App.update\")\n  public App updateAppInLocal(App app, String operator) {\n    validateOperator(operator);\n    String appId = app.getAppId();\n\n    App managedApp = appRepository.findByAppId(appId);\n    if (managedApp == null) {\n      throw BadRequestException.appNotExists(appId);\n    }\n\n    managedApp.setName(app.getName());\n    managedApp.setOrgId(app.getOrgId());\n    managedApp.setOrgName(app.getOrgName());\n\n    String ownerName = app.getOwnerName();\n    UserInfo owner = userService.findByUserId(ownerName);\n    if (owner == null) {\n      throw new BadRequestException(\"App's owner not exists. owner = %s\", ownerName);\n    }\n    managedApp.setOwnerName(owner.getUserId());\n    managedApp.setOwnerEmail(owner.getEmail());\n\n    managedApp.setDataChangeLastModifiedBy(operator);\n\n    return appRepository.save(managedApp);\n  }\n\n  public EnvClusterInfo createEnvNavNode(Env env, String appId) {\n    EnvClusterInfo node = new EnvClusterInfo(env);\n    node.setClusters(clusterService.findClusters(env, appId));\n    return node;\n  }\n\n  @Transactional\n  @ApolloAuditLog(type = OpType.DELETE, name = \"App.delete\")\n  public App deleteAppInLocal(String appId, String operator) {","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java#L213-L249","documentation":"Thrown by the AppService update path when userService.findByUserId(ownerName) returns null while editing an app. BadRequestException → HTTP 400. The %s is substituted with the offending ownerName via Strings.lenientFormat. Same ownership-validity guard as create, applied on update.","triggerScenarios":"Updating an app (PUT) and changing ownerName to a userId that does not exist in the user store.","commonSituations":"Reassigning ownership to a mistyped or not-yet-provisioned user; owner left the org and was removed from the directory; cross-system userId mismatch.","solutions":["Verify the new ownerName resolves via userService.findByUserId before submitting the update.","Provision the new owner in the user store first.","Keep ownerName aligned with the canonical directory userId."],"exampleFix":"// before\nmanagedApp.setOwnerName(newOwner);\nappService.updateApp(managedApp, operator);\n\n// after\nif (userService.findByUserId(newOwner) == null) {\n  throw new IllegalArgumentException(\"new owner \" + newOwner + \" does not exist\");\n}\nmanagedApp.setOwnerName(newOwner);\nappService.updateApp(managedApp, operator);","handlingStrategy":"validation","validationCode":"if (userService.findByUserId(ownerName) == null) {\n  return ResponseEntity.badRequest().body(\"new owner does not exist: \" + ownerName);\n}","typeGuard":"boolean isKnownOwner(String ownerName, UserService svc) { return svc.findByUserId(ownerName) != null; }","tryCatchPattern":null,"preventionTips":["Validate the new owner before reassigning app ownership.","Use the exact canonical directory userId."],"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"}