{"record":{"id":"e7ad905dd15633e6","repo":"iflytek/astron-agent","slug":"long-content-wrong-business-type","errorCode":"LONG_CONTENT_WRONG_BUSINESS_TYPE","errorMessage":"LONG_CONTENT_WRONG_BUSINESS_TYPE","messagePattern":"LONG_CONTENT_WRONG_BUSINESS_TYPE","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/chat/impl/ChatEnhanceServiceImpl.java","lineNumber":159,"sourceCode":"        return map;\n    }\n\n    /**\n     * Save file and return file ID mapping\n     *\n     * @param uid User ID\n     * @param vo Chat enhance file save object\n     * @return Map containing file ID and error information\n     */\n    @Override\n    public Map<String, String> saveFile(String uid, ChatEnhanceSaveFileVo vo) {\n        String fileName = vo.getFileName();\n        String fileUrl = vo.getFileUrl();\n        Long fileSize = vo.getFileSize();\n        Integer businessType = vo.getBusinessType();\n        // File extension and file type validation\n        if (!ChatFileLimitEnum.checkFileByBusinessType(fileName, businessType)) {\n            throw new BusinessException(ResponseEnum.LONG_CONTENT_WRONG_BUSINESS_TYPE);\n        }\n        // Convert to file type, determine whether to use the institute's interface based on the presence of\n        // fileBizType field\n        ChatFileLimitEnum limitEnum = ChatFileLimitEnum.getByValue(businessType);\n        checkFile(uid, fileName, fileUrl, fileSize, limitEnum);\n\n        Map<String, String> fileIdMap = documentHandler(null, uid, vo.getChatId(), fileUrl, fileName, fileSize,\n                limitEnum, vo.getFileBusinessKey(), vo.getDocumentType(), vo.getParamName());\n\n        if (fileIdMap == null) {\n            fileIdMap = new HashMap<>();\n            fileIdMap.put(\"file_id\", null);\n            fileIdMap.put(\"error_msg\", LongContextStatusEnum.FINALLY.getErrorMsg());\n        }\n        String fileId = fileIdMap.get(\"file_id\");\n        if (StringUtils.isBlank(fileId)) {\n            fileIdMap.put(\"error_msg\", LongContextStatusEnum.FINALLY.getErrorMsg());\n        }","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/chat/impl/ChatEnhanceServiceImpl.java#L141-L177","documentation":"Thrown in ChatEnhanceServiceImpl.saveFile when ChatFileLimitEnum.checkFileByBusinessType(fileName, businessType) returns false, i.e. the file's extension/type is not allowed for the given businessType. It wraps ResponseEnum.LONG_CONTENT_WRONG_BUSINESS_TYPE and is the upload entry point's format/business-type guard.","triggerScenarios":"saveFile(vo) reads fileName and businessType from the uploaded file VO; if the extension (from fileName) is not in the allowed set for that ChatFileLimitEnum business type, BusinessException(LONG_CONTENT_WRONG_BUSINESS_TYPE) is thrown before size/count checks run.","commonSituations":"Uploading a .exe/.zip or other disallowed extension to a chat that only accepts documents; sending a file with the wrong businessType value (e.g. audio-type businessType with a text document); fileName missing an extension so extension matching fails; client passing an out-of-range businessType integer.","solutions":["Check ChatFileLimitEnum.checkFileByBusinessType to see which extensions are allowed for your businessType and upload a matching file.","Verify the client sends the correct businessType for the file being uploaded.","Ensure fileName includes a proper extension; rename the file if the extension is missing or wrong.","If the type should be supported, extend the ChatFileLimitEnum allowed-extension mapping."],"exampleFix":"// before\nif (!ChatFileLimitEnum.checkFileByBusinessType(fileName, businessType)) {\n    throw new BusinessException(ResponseEnum.LONG_CONTENT_WRONG_BUSINESS_TYPE);\n}\n// after\nif (!ChatFileLimitEnum.checkFileByBusinessType(fileName, businessType)) {\n    log.warn(\"File type not allowed for businessType: {}, fileName: {}\", businessType, fileName);\n    throw new BusinessException(ResponseEnum.LONG_CONTENT_WRONG_BUSINESS_TYPE);\n}","handlingStrategy":"validation","validationCode":"// Client-side pre-check mirroring the server rule:\nif (!ChatFileLimitEnum.checkFileByBusinessType(fileName, businessType)) {\n    throw new BusinessException(ResponseEnum.LONG_CONTENT_WRONG_BUSINESS_TYPE);\n}","typeGuard":null,"tryCatchPattern":"try {\n    chatEnhanceService.saveFile(vo);\n} catch (BusinessException e) {\n    if (ResponseEnum.LONG_CONTENT_WRONG_BUSINESS_TYPE == e.getCode()) {\n        // show allowed file types for this businessType to the user\n    }\n}","preventionTips":["Enforce extension whitelists in the UI before upload.","Always send businessType consistent with the file kind.","Reject extension-less filenames early."],"tags":["file-upload","validation","file-type","chat"],"backgroundTag":"schema-validation-failed","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"}