iflytek/astron-agent · error · BusinessException
REPO_KNOWLEDGE_NOT_EXIST
REPO_KNOWLEDGE_NOT_EXIST
Error message
REPO_KNOWLEDGE_NOT_EXIST
What it means
BusinessException(REPO_KNOWLEDGE_NOT_EXIST) thrown at the start of updateKnowledge(KnowledgeVO) when knowledgeMapper.selectById returns null, i.e. no knowledge row exists with the id in the request. The update is rejected before any content mutation or repo-context resolution happens.
Solutions
- Re-fetch the knowledge list and confirm the id still exists before updating.
- Handle 'not exist' on save by prompting the user to reload (concurrent deletion).
- Verify the environment/database: ids do not transfer across deployments.
- If the id should exist, check whether a cleanup job or another user deleted it (audit logs).
Example fix
// before: blind update with cached id
await knowledgeApi.update({ id: cachedId, ...edits });
// after: refresh and re-locate
const fresh = await knowledgeApi.get(cachedId).catch(() => null);
if (!fresh) throw new Error('knowledge was deleted, reload required');
await knowledgeApi.update({ id: cachedId, ...edits }); Defensive patterns
Strategy: try-catch
Validate before calling
const existing = await knowledgeApi.get(vo.id).catch(() => null);
if (!existing) throw new Error(`knowledge ${vo.id} no longer exists`); Try / catch
try {
await knowledgeApi.update(vo);
} catch (e) {
if (e.code === 'REPO_KNOWLEDGE_NOT_EXIST') {
alert('This knowledge entry was deleted by another user. Reloading.');
return reloadKnowledgeList();
}
throw e;
} Prevention
- Re-fetch the record before save in long-lived editing sessions.
- Surface delete events to other editors (websocket/polling) to prevent stale edits.
- Keep per-environment ids out of shared scripts and fixtures.
When it happens
Trigger: Calling updateKnowledge with: an id that was already deleted, a malformed/non-existent id, or an id from a different environment (dev data used against prod).
Common situations: Two users editing the same knowledge entry, one deletes it while the other saves; stale browser tab holding a deleted record; automated scripts replaying captured update requests with stale ids.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/463c84289c6c4b55.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/KnowledgeService.java:168
log.error("Failed to save knowledge point", e);
throw e;
}
return knowledge;
}
/**
* Update knowledge entry
*
* @param knowledgeVO knowledge value object
* @return updated Knowledge object
* @throws BusinessException if knowledge not found or update fails
*/
@Transactional
public Knowledge updateKnowledge(KnowledgeVO knowledgeVO) {
MysqlKnowledge mysqlKnowledge = knowledgeMapper.selectById(knowledgeVO.getId());
if (mysqlKnowledge == null) {
throw new BusinessException(ResponseEnum.REPO_KNOWLEDGE_NOT_EXIST);
}
Knowledge knowledge = new Knowledge();
BeanUtils.copyProperties(mysqlKnowledge, knowledge);
RepoContext repoContext = getRepoContext(knowledgeVO.getFileId());
String originKnowledge = knowledge.getContent().getString("content");
boolean notNeedUpdate = originKnowledge.equals(knowledgeVO.getContent());
if (notNeedUpdate) {
return knowledge;
}
knowledge.getContent().put("content", knowledgeVO.getContent());
knowledge.setUpdatedAt(LocalDateTime.now());
Repo repo = repoService.getOnly(Wrappers.lambdaQuery(Repo.class).eq(Repo::getCoreRepoId, repoContext.coreRepoId));
dataPermissionCheckTool.checkRepoBelong(repo);
String auditSuggest = null;
if (repo.getEnableAudit()) {View on GitHub (pinned to 5e758547a8)