{"record":{"id":"015bc2af8fce66d7","repo":"iflytek/astron-agent","slug":"repo-type-not-match","errorCode":"REPO_TYPE_NOT_MATCH","errorMessage":"ResponseEnum.REPO_TYPE_NOT_MATCH","messagePattern":"ResponseEnum\\.REPO_TYPE_NOT_MATCH","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/RepoService.java","lineNumber":177,"sourceCode":"    }\n\n    /** Reject duplicate repo names in the current personal or space scope. */\n    private void validateRepoNameUnique(RepoVO repoVO, Long spaceId) {\n        Repo existRepo;\n        if (spaceId == null) {\n            existRepo = this.getOnly(Wrappers.lambdaQuery(Repo.class).eq(Repo::getUserId, UserInfoManagerHandler.getUserId()).eq(Repo::getName, repoVO.getName()).eq(Repo::getDeleted, 0));\n        } else {\n            existRepo = this.getOnly(Wrappers.lambdaQuery(Repo.class).eq(Repo::getSpaceId, spaceId).eq(Repo::getName, repoVO.getName()).eq(Repo::getDeleted, 0));\n        }\n        if (existRepo != null) {\n            throw new BusinessException(ResponseEnum.REPO_NAME_DUPLICATE);\n        }\n    }\n\n    /** Reject unsupported RAG tags. */\n    private void validateTag(String tag) {\n        if (!ProjectContent.isCbgRagCompatible(tag) && !ProjectContent.isAiuiRagCompatible(tag)) {\n            throw new BusinessException(ResponseEnum.REPO_TYPE_NOT_MATCH);\n        }\n    }\n\n    /** Ragflow-RAG always uses a server-generated core repo id. */\n    private String resolveCoreRepoId(RepoVO repoVO) {\n        if (ProjectContent.FILE_SOURCE_RAG_FLOW_RAG_STR.equals(repoVO.getTag())) {\n            return UUID.randomUUID().toString().replace(\"-\", \"\");\n        }\n        if (StringUtils.isEmpty(repoVO.getOuterRepoId())) {\n            return UUID.randomUUID().toString().replace(\"-\", \"\");\n        }\n        return repoVO.getOuterRepoId();\n    }\n\n    /** Build {@code repoName-coreRepoId}, trimming only the readable prefix. */\n    private String buildRagflowDatasetName(String repoName, String coreRepoId) {\n        String suffix = coreRepoId;\n        String readableName = StringUtils.defaultIfBlank(repoName, \"repo\").trim();","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/RepoService.java#L159-L195","documentation":"RepoService.validateTag throws REPO_TYPE_NOT_MATCH when a knowledge-base tag is neither CBG-RAG-compatible nor AIUI-RAG-compatible. The tag field of the incoming RepoVO must match one of the supported RAG types (checked via ProjectContent.isCbgRagCompatible/isAiuiRagCompatible); anything else is rejected at creation time by createRepo. This is an input-validation guard protecting downstream RAG integration code that only knows how to handle the supported tag families.","triggerScenarios":"Calling createRepo with a RepoVO whose tag is absent, empty, or set to an unsupported string (e.g. a legacy tag, typo like 'rag-flow-rag' vs FILE_SOURCE_RAG_FLOW_RAG_STR, or a tag from a different product line).","commonSituations":"API consumers hardcoding a tag copied from docs of another version; scripts creating repos in bulk with a default tag value that no longer exists after a rename in ProjectContent; frontend sending tag=null when the create form omits the RAG type selector.","solutions":["Set repoVO.tag to one of the supported RAG tag constants defined in ProjectContent (CBG-RAG or AIUI-RAG compatible values)","Check ProjectContent.isCbgRagCompatible / isAiuiRagCompatible in the client to validate the tag before calling createRepo","If the tag comes from an upstream enum/dictionary, sync it with the current ProjectContent constants (values may have been renamed)","Log the actual tag value at the call site to catch silent null/empty tags"],"exampleFix":"// before\nRepoVO vo = new RepoVO();\nvo.setName(\"kb\");\nvo.setTag(\"custom-rag\"); // unsupported\nrepoService.createRepo(vo);\n// after\nRepoVO vo = new RepoVO();\nvo.setName(\"kb\");\nvo.setTag(ProjectContent.FILE_SOURCE_RAG_FLOW_RAG_STR); // a supported tag\nrepoService.createRepo(vo);","handlingStrategy":"validation","validationCode":"if (!ProjectContent.isCbgRagCompatible(tag) && !ProjectContent.isAiuiRagCompatible(tag)) {\n    throw new IllegalArgumentException(\"Unsupported RAG tag: \" + tag);\n}\nrepoService.createRepo(vo);","typeGuard":"boolean isValidRagTag(String tag) {\n    return tag != null && (ProjectContent.isCbgRagCompatible(tag) || ProjectContent.isAiuiRagCompatible(tag));\n}","tryCatchPattern":"try {\n    repoService.createRepo(vo);\n} catch (BusinessException e) {\n    if (\"REPO_TYPE_NOT_MATCH\".equals(e.getCode())) {\n        // prompt user to select a supported RAG type\n    }\n}","preventionTips":["Always source tag values from ProjectContent constants, not string literals","Validate the tag in the frontend create form before submitting","Add a unit test asserting every tag constant used by callers passes validateTag"],"tags":["validation","knowledge-base","rag"],"backgroundTag":"invalid-argument-value","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"}