iflytek/astron-agent · error · BusinessException

DATA_NOT_EXIST

DATA_NOT_EXIST

Error message

DATA_NOT_EXIST

What it means

DataPermissionCheckTool.checkRepoBelong throws BusinessException(ResponseEnum.DATA_NOT_EXIST) when the Repo argument is null. The method is a permission gate: after the null check it compares the repo's spaceId/userId against the current request's space/uid and also throws DATA_NOT_EXIST (or denies) when ownership does not match. The intent is to make a non-existent record and a record the caller may not see indistinguishable.

Solutions

  1. Verify the repo id exists with repoMapper.selectById(id) before calling checkRepoBelong, and return a 404 to the client if null
  2. Check the request payload/path variable — a missing or malformed repoId resolves to no row
  3. Confirm the row is not soft-deleted and belongs to the environment/space you are querying against
  4. Catch BusinessException with code DATA_NOT_EXIST at the controller layer and map it to HTTP 404

Example fix

// before
Repo repo = repoMapper.selectById(id);
dataPermissionCheckTool.checkRepoBelong(repo);

// after
Repo repo = repoMapper.selectById(id);
if (repo == null) {
    throw new BusinessException(ResponseEnum.DATA_NOT_EXIST); // or return 404
}
dataPermissionCheckTool.checkRepoBelong(repo);
Defensive patterns

Strategy: try-catch

Validate before calling

Repo repo = repoMapper.selectById(repoId);
if (repo == null) { throw new BusinessException(ResponseEnum.DATA_NOT_EXIST); }

Type guard

if (repo != null) { dataPermissionCheckTool.checkRepoBelong(repo); }

Try / catch

try {
    dataPermissionCheckTool.checkRepoBelong(repo);
} catch (BusinessException e) {
    if (ResponseEnum.DATA_NOT_EXIST.getCode().equals(e.getCode())) {
        return ResponseEntity.notFound().build();
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling checkRepoBelong(repo) with a repo loaded by repoMapper.selectById(id) that returned null — i.e. an id that does not exist in the repo table, a soft-deleted repo, a wrong-tenant/space id, or an id from a stale client reference.

Common situations: Client passes a deleted or mistyped repository id; DB row was removed between listing and access; caller forgot a null check after selectById before invoking the permission tool; cross-space reference leaks an id the user never owned.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/tool/DataPermissionCheckTool.java:144

                "Permission check failed: action={}, uid={}, currentSpaceId={}, resourceType={}",
                action,
                uid,
                currentSpaceId(),
                resource == null ? null : resource.getClass().getSimpleName());
        throw new BusinessException(ResponseEnum.EXCEED_AUTHORITY);
    }

    // ===================== Repo / Tool / File =====================

    /**
     * Check repository ownership.
     *
     * @param repo the repository to check
     * @throws BusinessException if access denied or data not exists
     */
    public void checkRepoBelong(Repo repo) {
        if (repo == null)
            throw new BusinessException(ResponseEnum.DATA_NOT_EXIST);
        String uid = getThreadLocalUidNoNull();
        Long spaceId = currentSpaceId();

        boolean noPermission = spaceId != null
                ? !Objects.equals(repo.getSpaceId(), spaceId)
                : !Objects.equals(repo.getUserId(), uid.toString());

        if (noPermission)
            deny("checkRepoBelong", repo);
    }

    /**
     * Check repository visibility (supports space visibility/user visibility).
     *
     * @param repo the repository to check
     * @throws BusinessException if access denied or data not exists
     */
    public void checkRepoVisible(Repo repo) {

View on GitHub (pinned to 5e758547a8)