{"record":{"id":"ca07eac24f98da6b","repo":"iflytek/astron-agent","slug":"repo-knowledge-get-failed","errorCode":"REPO_KNOWLEDGE_GET_FAILED","errorMessage":"REPO_KNOWLEDGE_GET_FAILED","messagePattern":"REPO_KNOWLEDGE_GET_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/KnowledgeService.java","lineNumber":1045,"sourceCode":"            }\n            restoreManualKnowledge(uuid.get(0), uuid.get(2));\n        } catch (Exception e) {\n            log.error(\"Embedding failed\", e);\n            throw e;\n        }\n\n        return push.failedKnowledge.size();\n    }\n\n\n    private List<PreviewKnowledge> loadPreviewKnowledge(String lastUuid) {\n        // Criteria criteria = Criteria.where(\"fileId\").is(lastUuid);\n        // List<PreviewKnowledge> list = mongoTemplate.find(new Query(criteria), PreviewKnowledge.class);\n\n        // Use MySQL query to replace MongoDB query\n        List<MysqlPreviewKnowledge> mysqlList = previewKnowledgeMapper.findByFileId(lastUuid);\n        if (CollectionUtils.isEmpty(mysqlList)) {\n            throw new BusinessException(ResponseEnum.REPO_KNOWLEDGE_GET_FAILED);\n        }\n\n        List<PreviewKnowledge> list = new ArrayList<>();\n        for (MysqlPreviewKnowledge mysql : mysqlList) {\n            PreviewKnowledge preview = new PreviewKnowledge();\n            BeanUtils.copyProperties(mysql, preview);\n            list.add(preview);\n        }\n        return list;\n    }\n\n    private List<Knowledge> findOldAutoKnowledge(String docUuid) {\n        // Criteria c = Criteria.where(\"fileId\").is(docUuid).and(\"source\").is(0);\n        // return mongoTemplate.find(new Query(c), Knowledge.class);\n\n        // Use MySQL query to replace MongoDB query\n        List<MysqlKnowledge> mysqlList = knowledgeMapper.findByFileIdAndSource(docUuid, 0);\n        List<Knowledge> result = new ArrayList<>();","sourceCodeStart":1027,"sourceCodeEnd":1063,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/KnowledgeService.java#L1027-L1063","documentation":"BusinessException REPO_KNOWLEDGE_GET_FAILED thrown by loadPreviewKnowledge when previewKnowledgeMapper.findByFileId(lastUuid) returns an empty list. The embedding-confirm flow requires the preview chunks stored during document parsing to exist; no rows means the preview data is missing or was keyed under a different uuid, so processing cannot proceed.","triggerScenarios":"Calling the confirm/embed flow for a document whose preview_knowledge rows are absent for lastUuid: preview storage was skipped or failed during parse, the lastUuid convention changed (CBG uses chunk docId, others use file uuid — see updateLastUuidBySource), or the same document was re-parsed wiping rows.","commonSituations":"CBG docId/uuid mismatch after a backend upgrade changed the docId scheme. Rows deleted by a re-parse while a confirm was in flight. MySQL migration lost preview_knowledge data that used to live in MongoDB.","solutions":["Re-run document parsing/split to regenerate preview_knowledge rows for the file, then retry the embed/confirm call.","Verify the lastUuid derivation: for CBG confirm it equals chunkInfos[0].docId; ensure preview rows were stored under that same fileId.","Check preview_knowledge contents: SELECT COUNT(*) FROM preview_knowledge WHERE file_id = '<lastUuid>'.","Compare against previous parse results if a version upgrade changed docId generation; re-parse affected docs."],"exampleFix":"// before\nList<MysqlPreviewKnowledge> mysqlList = previewKnowledgeMapper.findByFileId(lastUuid);\nif (CollectionUtils.isEmpty(mysqlList)) { throw new BusinessException(ResponseEnum.REPO_KNOWLEDGE_GET_FAILED); }\n// after (degrade instead of hard fail)\nif (CollectionUtils.isEmpty(mysqlList)) {\n    log.warn(\"no preview knowledge for {}\", lastUuid);\n    return new ArrayList<>(); // or trigger re-parse\n}","handlingStrategy":"fallback","validationCode":"long n = previewKnowledgeMapper.count(new QueryWrapper<MysqlPreviewKnowledge>().eq(\"file_id\", lastUuid));\nif (n == 0) { reparseDocument(fileId); return; }","typeGuard":null,"tryCatchPattern":"try { return loadPreviewKnowledge(lastUuid); } catch (BusinessException e) { log.warn(\"preview knowledge missing for {}\", lastUuid); return Collections.emptyList(); }","preventionTips":["Re-parse documents after backend upgrades that change docId/lastUuid derivation.","Don't wipe preview rows while a confirm/embed flow may be in flight.","Verify the MySQL migration carried over preview_knowledge rows from MongoDB."],"tags":["database","empty-result","rag","chunking"],"backgroundTag":"empty-result-set","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"}