iflytek/astron-agent · error · BusinessException

REPO_STATUS_ILLEGAL

REPO_STATUS_ILLEGAL

Error message

ResponseEnum.REPO_STATUS_ILLEGAL

What it means

enableRepo computes the requested status transition: CREATED/PUBLISHED -> enabled=0 means UNPUBLISHED, UNPUBLISHED -> enabled=1 means PUBLISHED. Any other (status, enabled) combination — e.g. enabling an already-published repo, disabling an already-unpublished repo, or transitioning from intermediate statuses like BUILDING/FAILED — throws REPO_STATUS_ILLEGAL. It is a state-machine guard before updateRepoStatus.

Solutions

  1. Check repo.getStatus() first and only call enableRepo when the transition matches the allowed matrix (CREATED/PUBLISHED->0, UNPUBLISHED->1)
  2. Make callers idempotent: skip the call if the repo is already in the target state
  3. Wait for pending build/index processes to finish before publishing
  4. Catch BusinessException(REPO_STATUS_ILLEGAL), re-fetch current status, and reconcile the UI

Example fix

// before
repoService.enableRepo(id, 1); // fails if already published
// after
Repo repo = repoService.getById(id);
if (!Objects.equals(repo.getStatus(), ProjectContent.REPO_STATUS_PUBLISHED)) {
    repoService.enableRepo(id, 1);
}
Defensive patterns

Strategy: validation

Validate before calling

Repo repo = repoService.getById(id);
boolean valid =
    (Objects.equals(repo.getStatus(), ProjectContent.REPO_STATUS_CREATED)
  || Objects.equals(repo.getStatus(), ProjectContent.REPO_STATUS_PUBLISHED)) && enabled == 0
  || (Objects.equals(repo.getStatus(), ProjectContent.REPO_STATUS_UNPUBLISHED) && enabled == 1);
if (!valid) throw new IllegalStateException("Illegal repo status transition");

Try / catch

try {
    repoService.enableRepo(id, enabled);
} catch (BusinessException e) {
    if ("REPO_STATUS_ILLEGAL".equals(e.getCode())) {
        Repo cur = repoService.getById(id); // re-sync state
    }
}

Prevention

When it happens

Trigger: enabled=1 on a repo already in PUBLISHED status; enabled=0 on a repo already UNPUBLISHED; enabling/disabling a repo in a transitional status (building, indexing, failed) not covered by the two allowed branches.

Common situations: Idempotent retry of an enable call that already succeeded; double-click on the publish button; scripts assuming toggle semantics while the API expects exact target-state semantics; repos stuck in a failed build status being force-enabled.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/b95f55259a5ad88b. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/RepoService.java:894

     * @throws BusinessException if repository does not exist, user has no permission, or status
     *         transition is invalid
     */
    @Transactional
    public void enableRepo(Long id, Integer enabled) {
        Repo repo = this.getById(id);
        if (repo == null) {
            throw new BusinessException(ResponseEnum.REPO_NOT_EXIST);
        }
        dataPermissionCheckTool.checkRepoBelong(repo);
        RepoVO repoVO = new RepoVO();
        repoVO.setId(id);
        if ((Objects.equals(repo.getStatus(), ProjectContent.REPO_STATUS_CREATED)
                || Objects.equals(repo.getStatus(), ProjectContent.REPO_STATUS_PUBLISHED)) && enabled == 0) {
            repoVO.setOperType(ProjectContent.REPO_STATUS_UNPUBLISHED);
        } else if (Objects.equals(repo.getStatus(), ProjectContent.REPO_STATUS_UNPUBLISHED) && enabled == 1) {
            repoVO.setOperType(ProjectContent.REPO_STATUS_PUBLISHED);
        } else {
            throw new BusinessException(ResponseEnum.REPO_STATUS_ILLEGAL);
        }
        this.updateRepoStatus(repoVO);
    }


    public JSONObject deleteXinghuoDataset(HttpServletRequest request, String id) {
        Map<String, String> params = new HashMap<>();
        params.put("datasetId", id);

        Map<String, String> headers = new HashMap<>();
        String authorization = request.getHeader("Authorization");
        if (StringUtils.isNotBlank(authorization)) {
            headers.put("Authorization", authorization);
        }
        String response = OkHttpUtil.post(apiUrl.getDeleteXinghuoDatasetUrl(), params, headers, null);
        return JSON.parseObject(response);
    }

View on GitHub (pinned to 5e758547a8)