{"record":{"id":"61227259953e4176","repo":"OtterMind/Chat2DB","slug":"file-type-unsupported-612272","errorCode":"file.type.unsupported","errorMessage":"file.type.unsupported","messagePattern":"file\\.type\\.unsupported","errorType":"exception","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/ncx/TaskNcxImportServiceImpl.java","lineNumber":297,"sourceCode":"                insertDatasource(dataSourceResponse);\n            });\n        }\n\n        return uploadResponse;\n    }\n\n    @Override\n    public NcxImportResponse uploadFile(File file, ConfigFileTypeEnum fileType) {\n        if (ConfigFileTypeEnum.NCX == fileType) {\n            return ncxUploadFile(file);\n        }\n        if (ConfigFileTypeEnum.DBP == fileType) {\n            return dbpUploadFile(file);\n        }\n        if (ConfigFileTypeEnum.JSON == fileType) {\n            return chat2dbUploadFile(file);\n        }\n        throw new BusinessException(\"file.type.unsupported\");\n    }\n\n\n    @SneakyThrows\n    public int insertDBConfig(List<Map<String, Map<String, String>>> list) {\n        int n = 0;\n        for (Map<String, Map<String, String>> map : list) {\n            for (Map.Entry<String, Map<String, String>> valueMap : map.entrySet()) {\n                Map<String, String> resultMap = valueMap.getValue();\n                DataBaseTypeEnum dataBaseType = DataBaseTypeEnum.matchType(resultMap.get(\"ConnType\"));\n                WorkspaceDataSource dataSourceDO;\n                if (null == dataBaseType) {\n                    continue;\n                } else {\n                    dataSourceDO = new WorkspaceDataSource();\n                    dataSourceDO.setHost(resultMap.get(\"Host\"));\n                    dataSourceDO.setPort(resultMap.get(\"Port\"));\n                    dataSourceDO.setUrl(String.format(dataBaseType.getUrlString(), dataSourceDO.getHost(), dataSourceDO.getPort()));","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/ncx/TaskNcxImportServiceImpl.java#L279-L315","documentation":"BusinessException 'file.type.unsupported' from TaskNcxImportServiceImpl.uploadFile when the supplied ConfigFileTypeEnum is not one of NCX, DBP, or JSON. The dispatch chain exhausts without matching and throws.","triggerScenarios":"Calling uploadFile with a ConfigFileTypeEnum value other than NCX/DBP/JSON (e.g. an enum constant added later or SQL/CSV passed by mistake), or a null fileType.","commonSituations":"Client sends the wrong file-type discriminator for a config import; new enum added without an upload branch; integrator passes a default enum value.","solutions":["Send one of the supported file types: NCX, DBP, or JSON.","If a new type is required, add a matching branch (e.g. chat2dbUploadFile/ncxUploadFile) before the fall-through throw.","Validate the fileType against the supported set on the controller before calling uploadFile."],"exampleFix":"// before\nSet<ConfigFileTypeEnum> ok = EnumSet.of(NCX, DBP, JSON);\nif (!ok.contains(fileType)) throw new BusinessException(\"file.type.unsupported\");\n// after (extend support)\nif (ConfigFileTypeEnum.SQL == fileType) return sqlUploadFile(file);\n","handlingStrategy":"validation","validationCode":"java.util.Set<ConfigFileTypeEnum> ok = java.util.EnumSet.of(ConfigFileTypeEnum.NCX, ConfigFileTypeEnum.DBP, ConfigFileTypeEnum.JSON);\nif (fileType == null || !ok.contains(fileType)) throw new BusinessException(\"file.type.unsupported\");","typeGuard":"boolean isSupportedUploadType(ConfigFileTypeEnum t) {\n    return t == ConfigFileTypeEnum.NCX || t == ConfigFileTypeEnum.DBP || t == ConfigFileTypeEnum.JSON;\n}","tryCatchPattern":null,"preventionTips":["Whitelist fileType at the controller boundary.","When adding a new ConfigFileTypeEnum, add its upload branch in the same change.","Default the client selector to a supported type."],"tags":["import","config","validation","enum"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}