{"record":{"id":"339d98216f307439","repo":"iflytek/astron-agent","slug":"repo-not-exist-responseenum","errorCode":"REPO_NOT_EXIST","errorMessage":"ResponseEnum.REPO_NOT_EXIST","messagePattern":"ResponseEnum\\.REPO_NOT_EXIST","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":249,"sourceCode":"        groupVisibilityService.setRepoVisibility(repo.getId(), 1, visibility, repoVO.getUids());\n        return repo;\n    }\n\n\n    /**\n     * Update an existing repository with new information. Validates repository existence, ownership,\n     * and name uniqueness before updating.\n     *\n     * @param repoVO repository value object containing update information\n     * @return updated Repo object\n     * @throws BusinessException if repository does not exist, user has no permission, or name is\n     *         duplicate\n     */\n    @Transactional\n    public Repo updateRepo(RepoVO repoVO) {\n        Repo model = this.getById(repoVO.getId());\n        if (model == null) {\n            throw new BusinessException(ResponseEnum.REPO_NOT_EXIST);\n        }\n        dataPermissionCheckTool.checkRepoBelong(model);\n        Long spaceId = SpaceInfoUtil.getSpaceId();\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            if (!Objects.equals(existRepo.getId(), repoVO.getId())) {\n                throw new BusinessException(ResponseEnum.REPO_NAME_DUPLICATE);\n            }\n\n        }\n        Integer visibility = repoVO.getVisibility() == null ? 0 : repoVO.getVisibility();\n        model.setVisibility(visibility);\n        model.setName(repoVO.getName());","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/RepoService.java#L231-L267","documentation":"updateRepo loads the Repo by repoVO.getId() with this.getById(); if no row exists it throws REPO_NOT_EXIST. This means the update targeted a knowledge-base id that is not present in the repo table. Soft-deleted rows (deleted=1) are filtered by the ORM base layer, so deleting a repo then updating it also yields this error.","triggerScenarios":"PUT/update calls with a stale or fabricated repo id; updating a repo that was already (soft-)deleted; a wrong id type/casting so getById finds nothing; cross-space access where the row exists but MyBatis-Plus logical-delete filtering hides it.","commonSituations":"Frontend cached a repo list, user deleted the repo in another tab, then saved edits; automated scripts replaying updates against ids from an older environment; integration tests using seeded ids that were rolled back.","solutions":["Fetch the current repo id (GET repo detail) before updating and retry with the fresh id","Check the repo was not deleted (deleted=0) — if deleted, recreate or restore instead of updating","Verify the environment/datasource: an id from one deployment does not exist in another database","Guard the client: treat 404-style REPO_NOT_EXIST as 'resource gone' and refresh the local list"],"exampleFix":"// before\nrepoService.updateRepo(staleVo);\n// after\nif (repoService.getById(staleVo.getId()) == null) {\n    throw new BusinessException(ResponseEnum.REPO_NOT_EXIST); // surfaced early\n}\nrepoService.updateRepo(staleVo);","handlingStrategy":"try-catch","validationCode":"if (repoService.getById(repoVO.getId()) == null) {\n    throw new BusinessException(ResponseEnum.REPO_NOT_EXIST);\n}","typeGuard":null,"tryCatchPattern":"try {\n    repoService.updateRepo(vo);\n} catch (BusinessException e) {\n    if (\"REPO_NOT_EXIST\".equals(e.getCode())) {\n        refreshRepoList(); // stale id — reload\n    }\n}","preventionTips":["Refresh cached repo ids before update operations","Never reuse ids across environments","Treat deleted repos as permanently gone; recreate instead of updating","Check getById before update in scripts"],"tags":["knowledge-base","not-found","crud"],"backgroundTag":"record-not-found","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"}