{"record":{"id":"d5700dc8b3f955bf","repo":"iflytek/astron-agent","slug":"8732-repo-knowledge-tag-too-long-d5700d","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/KnowledgeController.java","lineNumber":67,"sourceCode":"    }\n\n    /**\n     * Update knowledge\n     *\n     * @param knowledgeVO knowledge update request object containing updated knowledge details\n     * @return ApiResult<Knowledge> containing the updated knowledge information\n     * @throws ExecutionException if the computation threw an exception\n     * @throws InterruptedException if the thread is interrupted\n     * @throws BusinessException if tag length exceeds 30 characters\n     */\n    @PostMapping(\"/update-knowledge\")\n    @SpacePreAuth(key = \"KnowledgeController_updateKnowledge_POST\",\n            module = \"Knowledge\", point = \"Update Knowledge\", description = \"Update Knowledge\")\n    public ApiResult<Knowledge> updateKnowledge(@RequestBody KnowledgeVO knowledgeVO) throws ExecutionException, InterruptedException {\n        if (CollectionUtils.isNotEmpty(knowledgeVO.getTags())) {\n            for (String tag : knowledgeVO.getTags()) {\n                if (tag.length() > 30) {\n                    throw new BusinessException(ResponseEnum.REPO_KNOWLEDGE_TAG_TOO_LONG);\n                }\n            }\n        }\n        return ApiResult.success(knowledgeService.updateKnowledge(knowledgeVO));\n    }\n\n    /**\n     * Enable or disable knowledge\n     *\n     * @param id knowledge ID to be enabled or disabled\n     * @param enabled status flag: 1 to enable, 0 to disable\n     * @return ApiResult<String> containing operation result message\n     * @throws ExecutionException if the computation threw an exception\n     * @throws InterruptedException if the thread is interrupted\n     */\n    @PutMapping(\"/enable-knowledge\")\n    @SpacePreAuth(key = \"KnowledgeController_enableKnowledge_PUT\",\n            module = \"Knowledge\", point = \"Enable Knowledge\", description = \"Enable Knowledge\")","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/controller/knowledge/KnowledgeController.java#L49-L85","documentation":"BusinessException thrown by KnowledgeController.updateKnowledge when any tag in the knowledge VO exceeds 30 characters. The controller validates each string in knowledgeVO.getTags() before delegating to knowledgeService, rejecting the whole update if a single tag is too long. It is a client-input validation error (code 8732, message 'repo.knowledge.tag.too.long').","triggerScenarios":"PUT/POST to the knowledge update endpoint with a request body whose tags array contains any string with length > 30 characters, e.g. {\"tags\":[\"a-very-long-tag-name-that-exceeds-thirty-characters\"]}.","commonSituations":"Frontend forms without maxlength on the tag input; pasted labels or auto-generated tags (file names, UUIDs) longer than 30 chars; API consumers integrating directly without knowing the tag length cap.","solutions":["Shorten every tag in the tags array to 30 characters or fewer before calling the API.","Truncate or split long tags client-side before submitting the update.","If a longer tag is legitimately needed, raise the limit in KnowledgeController.updateKnowledge and any persisted-column width accordingly.","Return a clearer message naming the offending tag and its length in the error response."],"exampleFix":"// before\nknowledge.setTags(Arrays.asList(\"marketing-campaign-2026-q3-automated-segmentation-dashboard\"));\n// after\nString tag = \"marketing-campaign-2026-q3-automated-segmentation-dashboard\";\nknowledge.setTags(Arrays.asList(tag.length() > 30 ? tag.substring(0, 30) : tag));","handlingStrategy":"validation","validationCode":"function canSubmitKnowledge(vo) {\n  return !vo.tags || vo.tags.every(t => typeof t === 'string' && t.length <= 30);\n}","typeGuard":"const isValidTag = (t: unknown): t is string => typeof t === 'string' && t.length > 0 && t.length <= 30;","tryCatchPattern":"try {\n  await api.updateKnowledge(vo);\n} catch (e) {\n  if (e.code === 8732) {\n    vo.tags = vo.tags.map(t => t.slice(0, 30));\n    await api.updateKnowledge(vo);\n  } else throw e;\n}","preventionTips":["Set maxLength={30} on tag inputs in the UI.","Truncate or split tags at input time, not at submit time.","Document the 30-char limit in API docs and OpenAPI schema (maxLength: 30).","Trim whitespace before checking length to avoid surprise rejections."],"tags":["validation","input-length","knowledge-base"],"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"}