{"record":{"id":"55bbd22caf871e43","repo":"apolloconfig/apollo","slug":"orgname-can-not-be-blank","errorCode":null,"errorMessage":"orgName can not be blank","messagePattern":"orgName can not be blank","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java","lineNumber":303,"sourceCode":"    throw new BadRequestException(\"Unsupported auth type: %s\", authType);\n  }\n\n  private void validatePortalApp(OpenAppDTO app) {\n    if (!UserIdentityConstants.USER.equals(UserIdentityContextHolder.getAuthType())) {\n      return;\n    }\n    if (!StringUtils.hasText(app.getName())) {\n      throw BadRequestException.appNameIsBlank();\n    }\n    if (!InputValidator.isValidClusterNamespace(app.getAppId())) {\n      throw new BadRequestException(\"Invalid AppId format: %s\",\n          InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE);\n    }\n    if (!StringUtils.hasText(app.getOrgId())) {\n      throw BadRequestException.orgIdIsBlank();\n    }\n    if (!StringUtils.hasText(app.getOrgName())) {\n      throw new BadRequestException(\"orgName can not be blank\");\n    }\n    if (!StringUtils.hasText(app.getOwnerName())) {\n      throw BadRequestException.ownerNameIsBlank();\n    }\n  }\n\n  private Set<String> findAppIdsAuthorizedByCurrentIdentity() {\n    if (UserIdentityConstants.USER.equals(UserIdentityContextHolder.getAuthType())) {\n      UserInfo loginUser = userInfoHolder.getUser();\n      if (loginUser == null || !StringUtils.hasText(loginUser.getUserId())) {\n        return Collections.emptySet();\n      }\n      Set<String> appIds = new LinkedHashSet<>();\n      List<Role> userRoles = rolePermissionService.findUserRoles(loginUser.getUserId());\n      if (userRoles == null) {\n        return appIds;\n      }\n      for (Role role : userRoles) {","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java#L285-L321","documentation":"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.","triggerScenarios":"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 \"\".","commonSituations":"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.","solutions":["Provide a non-blank orgName in the app object (e.g., 'Engineering', 'Finance').","Ensure the Portal UI form requires orgName before submission (client-side validation).","If creating apps via API with a USER token, always set orgName explicitly."],"exampleFix":"// before\napp.setOrgName(\"\");\n\n// after\napp.setOrgName(\"Engineering\");","handlingStrategy":"validation","validationCode":"// Validate orgName is present before app creation (USER auth)\nif (!StringUtils.hasText(app.getOrgName())) {\n    throw new IllegalArgumentException(\"orgName must not be blank\");\n}","typeGuard":"public static boolean hasValidOrgName(OpenAppDTO app) {\n    return app != null && StringUtils.hasText(app.getOrgName());\n}","tryCatchPattern":null,"preventionTips":["Always populate orgName when creating or updating apps via the Portal UI.","Add client-side form validation that requires orgName.","Default orgName from the user's department or org selection if available."],"tags":["openapi","validation","apollo-portal","app-creation","organization","format"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}