{"record":{"id":"3d6c40f1624b7bd0","repo":"apolloconfig/apollo","slug":"invalid-appid-format-s","errorCode":null,"errorMessage":"Invalid AppId format: %s","messagePattern":"Invalid AppId format: (.+?)","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java","lineNumber":296,"sourceCode":"      }\n      if (userService.findByUserId(operator) == null) {\n        throw BadRequestException.userNotExists(operator);\n      }\n      return operator;\n    }\n\n    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();","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java#L278-L314","documentation":"Thrown by AppController.validatePortalApp when the auth type is USER and the appId does not match the InputValidator.CLUSTER_NAMESPACE_VALIDATOR pattern: [0-9a-zA-Z_-]+[0-9a-zA-Z_.-]*. This means the appId must start with a digit, letter, hyphen, or underscore, and subsequent characters can also include dots (but not a single dot alone). The error message includes the constant INVALID_CLUSTER_NAMESPACE_MESSAGE. Results in HTTP 400.","triggerScenarios":"Creating or updating an app (createApp, updateApp, createAppInEnv) with a USER identity where app.getAppId() contains spaces, special characters like @, #, /, or starts with a dot. For non-USER auth types, this validation is skipped entirely.","commonSituations":"A user enters an appId with spaces or special characters in the Portal UI. An appId starts with a dot (e.g., '.myapp'). A copy-paste introduced invisible characters. The appId contains a slash (common when people try to use a path-like identifier).","solutions":["Use only digits, letters, hyphens, underscores, and dots in the appId, ensuring it does not start with a dot.","Sanitize the appId input on the client side before submission.","Follow Apollo's naming convention: a short alphanumeric identifier like 'my-app' or 'payment-service'."],"exampleFix":"// before\napp.setAppId(\"my app@v2\");\n\n// after\napp.setAppId(\"my-app-v2\");","handlingStrategy":"validation","validationCode":"// Validate appId format before creating/updating an app (USER auth)\nif (!InputValidator.isValidClusterNamespace(app.getAppId())) {\n    throw new IllegalArgumentException(\n        \"Invalid AppId format: \" + InputValidator.INVALID_CLUSTER_NAMESPACE_MESSAGE);\n}","typeGuard":"public static boolean hasValidAppIdFormat(String appId) {\n    return InputValidator.isValidClusterNamespace(appId);\n}","tryCatchPattern":null,"preventionTips":["Run InputValidator.isValidClusterNamespace on the appId client-side before submission.","Use a naming convention that only uses letters, digits, hyphens, and underscores.","Sanitize user input by stripping whitespace and rejecting special characters early."],"tags":["openapi","validation","apollo-portal","appid","input-validator","format"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}