{"record":{"id":"2c86df80b671ec7f","repo":"iflytek/astron-agent","slug":"repo-knowledge-modify-failed","errorCode":"REPO_KNOWLEDGE_MODIFY_FAILED","errorMessage":"ResponseEnum.REPO_KNOWLEDGE_MODIFY_FAILED","messagePattern":"ResponseEnum\\.REPO_KNOWLEDGE_MODIFY_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":1593,"sourceCode":"            JSONArray updateChunkArray) {\n        List<String> resultList = new ArrayList<>();\n        if (!updateChunkArray.isEmpty()) { // Delete document\n            KnowledgeRequest request = new KnowledgeRequest();\n            request.setDocId(docId);\n            request.setGroup(group);\n            request.setChunks(updateChunkArray.toArray());\n            FileInfoV2 fileInfoV2 = fileInfoV2Service.getOnly(new QueryWrapper<FileInfoV2>().eq(\"uuid\", docId));\n            if (fileInfoV2 == null) {\n                throw new BusinessException(ResponseEnum.REPO_FILE_NOT_EXIST);\n            }\n\n            request.setRagType(fileInfoV2.getSource());\n            applyRagflowDatasetId(request, fileInfoV2.getSource(), datasetId);\n\n            KnowledgeResponse response = knowledgeV2ServiceCallHandler.updateChunk(request);\n            if (response.getCode() != 0) {\n                log.error(\"Failed to modify knowledge point, message:{}\", response.getMessage());\n                throw new BusinessException(ResponseEnum.REPO_KNOWLEDGE_MODIFY_FAILED);\n            }\n            JSONObject data = (JSONObject) response.getData();\n            if (data != null) {\n                JSONObject failedChunk = data.getJSONObject(\"failedChunk\");\n                if (failedChunk != null) {\n                    String errListStr = failedChunk.getString(\"chunkId\");\n                    if (!StringUtils.isEmpty(errListStr)) {\n                        String[] errIds = errListStr.split(\",\");\n                        log.error(\"failed repoId:{},  errIds:{}\", group, errIds);\n                        resultList = Arrays.asList(errIds);\n                    }\n                }\n            }\n        }\n        return resultList;\n    }\n\n    /**","sourceCodeStart":1575,"sourceCodeEnd":1611,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/KnowledgeService.java#L1575-L1611","documentation":"KnowledgeService updates a chunk via knowledgeV2ServiceCallHandler.updateChunk(request). If the upstream knowledge service answers with code != 0, it logs 'Failed to modify knowledge point' and throws BusinessException(REPO_KNOWLEDGE_MODIFY_FAILED). The code path also inspects response data for failedChunk entries afterwards, but a non-zero code short-circuits with this exception.","triggerScenarios":"updateChunk is called with a chunkId/docId the upstream service cannot modify: chunk already deleted upstream, invalid ragType or missing ragflowDatasetId, concurrent modification conflict, or upstream service error/timeout surfaced as a non-zero code.","commonSituations":"Two users editing the same knowledge point; chunk deleted by another flow between listing and update; RAGFlow dataset re-created so dataset IDs are stale; upstream knowledge service contract changed after an upgrade.","solutions":["Check the log line 'Failed to modify knowledge point, message:{}' for the upstream reason.","Re-list chunks for the docId and verify the chunkId still exists before retrying the update.","Validate ragType/source and the resolved ragflowDatasetId match the file's current state.","Retry after resolving conflicts; if the chunk is gone upstream, re-create it rather than updating."],"exampleFix":"// before\nKnowledgeResponse response = knowledgeV2ServiceCallHandler.updateChunk(request);\n// code!=0 -> REPO_KNOWLEDGE_MODIFY_FAILED\n\n// after\nKnowledgeResponse response = knowledgeV2ServiceCallHandler.updateChunk(request);\nif (response.getCode() != 0) {\n    log.warn(\"updateChunk failed chunkId={} msg={}\", chunkId, response.getMessage());\n    // verify chunk still exists upstream / fix datasetId, then retry\n}","handlingStrategy":"retry","validationCode":"// verify chunk still exists before update\nList<String> chunkIds = knowledgeService.listChunkIds(docId);\nif (!chunkIds.contains(chunkId)) { /* re-create instead of update */ }","typeGuard":null,"tryCatchPattern":"try {\n    knowledgeService.updateChunk(request);\n} catch (BusinessException e) {\n    if (ResponseEnum.REPO_KNOWLEDGE_MODIFY_FAILED.getCode().equals(e.getCode())) {\n        // re-list chunks; if missing, create; else retry after backoff\n    } else { throw e; }\n}","preventionTips":["Re-list chunks immediately before update to catch concurrent deletes.","Use optimistic concurrency or version fields for knowledge points.","Log the upstream message on every non-zero response code.","Validate ragType and datasetId after any RAGFlow dataset recreation."],"tags":["java","ragflow","upstream-error","concurrency"],"backgroundTag":"upstream-api-error","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"}