{"record":{"id":"30bd89e3b0dc7ad3","repo":"iflytek/astron-agent","slug":"8732-repo-knowledge-tag-too-long","errorCode":"8732","errorMessage":"repo.knowledge.tag.too.long","messagePattern":"repo\\.knowledge\\.tag\\.too\\.long","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/controller/knowledge/FileController.java","lineNumber":265,"sourceCode":"            @RequestParam(value = \"isRepoPage\", defaultValue = \"1\") Integer isRepoPage,\n            HttpServletRequest request) {\n        return fileInfoV2Service.queryFileList(repoId, parentId, pageNo, pageSize, tag, request, isRepoPage);\n    }\n\n    /**\n     * Create a new folder in the specified repository and parent directory Validates that tag length\n     * does not exceed 30 characters\n     *\n     * @param folderVO the folder creation request object containing folder name, parent ID, and tags\n     * @return ApiResult with void data indicating successful folder creation\n     * @throws BusinessException when tag length exceeds 30 characters or folder creation fails\n     */\n    @PostMapping(\"/create-folder\")\n    public ApiResult<Void> createFolder(@RequestBody CreateFolderVO folderVO) {\n        if (CollectionUtils.isNotEmpty(folderVO.getTags())) {\n            for (String tag : folderVO.getTags()) {\n                if (tag.length() > 30) {\n                    throw new BusinessException(ResponseEnum.REPO_KNOWLEDGE_TAG_TOO_LONG);\n                }\n            }\n        }\n\n        fileInfoV2Service.createFolder(folderVO);\n        return ApiResult.success();\n    }\n\n    /**\n     * Update existing folder properties such as name, tags, or metadata\n     *\n     * @param folderVO the folder update request object containing folder ID and updated properties\n     * @return ApiResult with void data indicating successful folder update\n     * @throws BusinessException when folder update fails or folder is not found\n     */\n    @PostMapping(\"/update-folder\")\n    public ApiResult<Void> updateFolder(@RequestBody CreateFolderVO folderVO) {\n        fileInfoV2Service.updateFolder(folderVO);","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/controller/knowledge/FileController.java#L247-L283","documentation":"FileController.createFolder validates each tag in the CreateFolderVO payload before creating the folder; any tag longer than 30 characters throws BusinessException(ResponseEnum.REPO_KNOWLEDGE_TAG_TOO_LONG, code 8732) with the message key 'repo.knowledge.tag.too.long'. It enforces the knowledge-base folder tag length limit before any persistence happens.","triggerScenarios":"POSTing to /create-folder with a body whose tags array contains at least one string whose length() exceeds 30 characters (counted in Java chars, not bytes/graphemes).","commonSituations":"Users pasting long phrases or whole sentences as tags in the UI; front-end lacking a 30-char maxlength on tag inputs; CJK or emoji tags where developers misjudge limits (emoji count as 2 Java chars); API clients sending unbounded tag arrays from scripts.","solutions":["Trim or shorten each tag to 30 characters or fewer before calling createFolder.","Add a 30-character maxlength validation on tag inputs in the frontend.","Strip whitespace and reject empty tags too, to avoid redundant failures.","If tags are auto-generated from names/descriptions, truncate them programmatically before sending."],"exampleFix":"// before\nawait api.post('/create-folder', { name, tags: userTags }); // may exceed 30 chars\n// after\nconst safeTags = userTags.map(t => t.trim().slice(0, 30)).filter(Boolean);\nawait api.post('/create-folder', { name, tags: safeTags });","handlingStrategy":"validation","validationCode":"if (tags?.some(t => t.length > 30)) { alert('Each tag must be 30 characters or fewer'); return; }","typeGuard":"function tagsWithinLimit(tags, max = 30) { return Array.isArray(tags) && tags.every(t => typeof t === 'string' && t.length <= max); }","tryCatchPattern":"try { await api.createFolder(vo); } catch (BusinessException e) { if (e.getCode() == 8732) { showToast(\"Tag exceeds 30 characters\"); } else throw e; }","preventionTips":["Set maxlength=30 on tag inputs in the UI","Trim and truncate tags before sending","Count emoji as 2 chars (Java length) when limiting","Filter out empty tags before submission"],"tags":["validation","knowledge-base","tags","length-limit"],"backgroundTag":"value-out-of-range","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}