{"record":{"id":"e37508954a1c5d52","repo":"apolloconfig/apollo","slug":"appid-is-null-or-blank","errorCode":null,"errorMessage":"AppId is null or blank","messagePattern":"AppId is null or 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":96,"sourceCode":"    this.userInfoHolder = userInfoHolder;\n    this.rolePermissionService = rolePermissionService;\n    this.unifiedPermissionValidator = unifiedPermissionValidator;\n  }\n\n  /**\n   * @see com.ctrip.framework.apollo.portal.controller.AppController#create(AppModel)\n   */\n  @Transactional\n  @PreAuthorize(value = \"@unifiedPermissionValidator.hasCreateApplicationPermission()\")\n  @ApolloAuditLog(type = OpType.CREATE, name = \"App.create\")\n  @Override\n  public ResponseEntity<Void> createApp(OpenCreateAppDTO req) {\n    if (null == req.getApp()) {\n      throw new BadRequestException(\"App is null\");\n    }\n    final OpenAppDTO app = req.getApp();\n    if (!StringUtils.hasText(app.getAppId())) {\n      throw new BadRequestException(\"AppId is null or blank\");\n    }\n    validatePortalApp(app);\n    String resolvedOperator = resolveOperator(app.getDataChangeCreatedBy());\n    app.setDataChangeCreatedBy(resolvedOperator);\n    app.setDataChangeLastModifiedBy(resolvedOperator);\n    this.appOpenApiService.createApp(req, resolvedOperator);\n    if (Boolean.TRUE.equals(req.getAssignAppRoleToSelf())\n        && UserIdentityConstants.CONSUMER.equals(UserIdentityContextHolder.getAuthType())) {\n      long consumerId = this.consumerAuthUtil.retrieveConsumerIdFromCtx();\n      consumerService.assignAppRoleToConsumer(consumerId, app.getAppId(), resolvedOperator);\n    }\n    return ResponseEntity.ok().build();\n  }\n\n  @Override\n  public ResponseEntity<List<OpenEnvClusterInfo>> getEnvClusterInfo(String appId) {\n    requireReadApplicationPermissionForUserToken(appId);\n    if (!hasReadApplicationPermissionForCurrentIdentity(appId)) {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java#L78-L114","documentation":"Thrown by AppController.createApp after confirming the app object is non-null but its appId field is blank (null, empty, or whitespace-only). The appId is the primary identifier for an Apollo application and must be provided at creation time. StringUtils.hasText(app.getAppId()) returns false for null, \"\", or \"   \". Results in HTTP 400.","triggerScenarios":"Sending a create-app request where the app object exists but appId is missing, empty, or contains only whitespace. For example: {\"app\": {\"name\": \"My App\"}} without an appId field.","commonSituations":"A client assumes the server will auto-generate the appId, but Apollo requires it upfront. The appId field was populated from a variable that evaluated to null at runtime. JSON key naming mismatch (e.g., app_id vs appId).","solutions":["Provide a non-blank appId in the app object — it must match the pattern [0-9a-zA-Z_-]+[0-9a-zA-Z_.-]*.","Generate the appId deterministically (e.g., project prefix + sequence) before sending the request.","Check for typos in the JSON field name (camelCase appId, not app_id)."],"exampleFix":"// before\nOpenAppDTO app = new OpenAppDTO();\napp.setName(\"My App\");\n// appId not set\n\n// after\nOpenAppDTO app = new OpenAppDTO();\napp.setAppId(\"my-app-001\");\napp.setName(\"My App\");","handlingStrategy":"validation","validationCode":"// Validate appId is present before creating the app\nOpenAppDTO app = req.getApp();\nif (app.getAppId() == null || app.getAppId().trim().isEmpty()) {\n    throw new IllegalArgumentException(\"appId must not be null or blank\");\n}","typeGuard":"public static boolean hasValidAppId(OpenAppDTO app) {\n    return app != null && app.getAppId() != null && !app.getAppId().trim().isEmpty();\n}","tryCatchPattern":null,"preventionTips":["Always set a non-blank appId when constructing the app object.","Generate appIds programmatically with a deterministic scheme to avoid manual omissions.","Validate all required fields client-side before submitting the create request."],"tags":["openapi","app-creation","validation","apollo-portal","appid"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}