{"record":{"id":"aa4f610fa8dd11c3","repo":"iflytek/astron-agent","slug":"repo-file-disabled","errorCode":"REPO_FILE_DISABLED","errorMessage":"ResponseEnum.REPO_FILE_DISABLED","messagePattern":"ResponseEnum\\.REPO_FILE_DISABLED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/RepoService.java","lineNumber":779,"sourceCode":"        }\n        if (isBelongLoginUser) {\n            dataPermissionCheckTool.checkRepoBelong(repo);\n        }\n\n        List<FileDirectoryTree> fileDirectoryTrees = directoryTreeService.list(Wrappers.lambdaQuery(FileDirectoryTree.class).eq(FileDirectoryTree::getAppId, repo.getId()).eq(FileDirectoryTree::getIsFile, 1));\n        if (CollectionUtils.isEmpty(fileDirectoryTrees)) {\n            return new JSONArray();\n        }\n        boolean hasEnabledFile = false;\n        for (FileDirectoryTree fileDirectoryTree : fileDirectoryTrees) {\n            FileInfoV2 fileInfoV2 = fileInfoV2Service.getById(fileDirectoryTree.getFileId());\n            if (fileInfoV2 != null && fileInfoV2.getEnabled() == 1) {\n                hasEnabledFile = true;\n                break;\n            }\n        }\n        if (!hasEnabledFile) {\n            throw new BusinessException(ResponseEnum.REPO_FILE_DISABLED);\n        }\n\n        QueryRequest request = this.getKnowledgeQueryObject(repo, topN, query);\n\n        KnowledgeResponse resp = knowledgeV2ServiceCallHandler.knowledgeQuery(request);\n        if (resp.getCode() != 0) {\n            log.error(\"Knowledge retrieval failed, message:{}\", resp.getMessage());\n            throw new BusinessException(ResponseEnum.REPO_KNOWLEDGE_QUERY_FAILED);\n        }\n\n        HitTestHistory hitTestHistory = new HitTestHistory();\n        hitTestHistory.setRepoId(id);\n        hitTestHistory.setUserId(UserInfoManagerHandler.getUserId());\n        hitTestHistory.setQuery(query);\n        hitTestHistory.setCreateTime(new Timestamp(System.currentTimeMillis()));\n        historyService.save(hitTestHistory);\n\n        QueryRespData data = JSON.parseObject(resp.getData().toString(), QueryRespData.class);","sourceCodeStart":761,"sourceCodeEnd":797,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/RepoService.java#L761-L797","documentation":"During hitTest, RepoService scans the repo's files (fileInfoV2 records) and throws REPO_FILE_DISABLED when none of them has enabled == 1. A repo with zero enabled documents cannot answer queries, so retrieval is refused before calling the knowledge service.","triggerScenarios":"Running hitTest on a repo whose documents were all disabled (enabled=0), or a repo created but with no enabled files indexed yet; files disabled after a failed indexing/publish cycle.","commonSituations":"User unpublished a knowledge base (disabling its files) and later runs a hit test; batch import left files pending/disabled; admin toggled files off while debugging and forgot to re-enable.","solutions":["Enable at least one file in the repo (set enabled=1 via the file management API) and re-run the hit test","Re-publish/re-enable the repo if it was unpublished (see enableRepo with enabled=1)","Check document processing status — re-upload or re-index files stuck in disabled state","Catch REPO_FILE_DISABLED client-side and show 'enable documents before testing retrieval'"],"exampleFix":"// before\nhitTest(repoId, ...); // all files disabled\n// after\nfileService.enableFile(fileId, 1); // enable a document first\nhitTest(repoId, ...);","handlingStrategy":"validation","validationCode":"List<FileInfoV2> files = fileInfoService.listByRepoId(repoId);\nboolean anyEnabled = files.stream().anyMatch(f -> f.getEnabled() == 1);\nif (!anyEnabled) {\n    throw new IllegalStateException(\"Enable at least one document before hit test\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    repoService.hitTest(repoId, query, topN, true);\n} catch (BusinessException e) {\n    if (\"REPO_FILE_DISABLED\".equals(e.getCode())) {\n        // guide user to enable documents\n    }\n}","preventionTips":["Enable at least one file before testing retrieval","Re-publish repos after unpublishing to re-enable files","Monitor indexing pipeline so files do not remain stuck disabled","Surface enabled-file count in the UI before hit test"],"tags":["knowledge-base","hit-test","disabled-state"],"backgroundTag":"feature-not-enabled","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}