iflytek/astron-agent · error · BusinessException

DATABASE_NOT_EXIST

DATABASE_NOT_EXIST

Error message

DATABASE_NOT_EXIST

What it means

Thrown by DatabaseService.createDbTable when dbInfoMapper.selectById(dbTableDto.getDbId()) returns null, meaning the target database does not exist (or was soft-deleted). The table creation cannot proceed without a valid parent database. Permission to the db is checked just before this, so it is a pure existence check.

Solutions

  1. Fetch the database list and confirm the dbId exists before creating tables
  2. Re-select the target database in the UI to refresh a stale id
  3. Verify you are using the local DbInfo id, not the core-system dbId, in the request
  4. If soft-deleted, recreate the database first

Example fix

// before
dbTableDto.setDbId(deletedOrUnknownId);
databaseService.createDbTable(dbTableDto);
// after
DbInfo db = databaseService.getById(dbId);
if (db != null) { dbTableDto.setDbId(db.getId()); databaseService.createDbTable(dbTableDto); }
Defensive patterns

Strategy: validation

Validate before calling

DbInfo db = dbInfoMapper.selectById(dbId);
if (db == null || Boolean.TRUE.equals(db.getDeleted())) { throw new IllegalStateException("database does not exist: " + dbId); }

Type guard

boolean dbExists(DbTableDto dto) { DbInfo d = dbInfoMapper.selectById(dto.getDbId()); return d != null && !Boolean.TRUE.equals(d.getDeleted()); }

Try / catch

try { databaseService.createDbTable(dto); } catch (BusinessException e) { if ("DATABASE_NOT_EXIST".equals(e.getCode())) { /* refresh db list / ask user to reselect */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling createDbTable with a dbId that is not present in db_info, or one whose deleted flag is true; stale dbId from a deleted database; wrong dbId typed/serialized by the client.

Common situations: UI cached an old database list after the DB was deleted elsewhere; API consumer passes core-system dbId instead of the local DbInfo primary key; copy/paste of ids across environments (dev vs prod).

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/8830bb0b40917643. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:278

                lqw.isNull(DbInfo::getSpaceId);
                lqw.eq(DbInfo::getUid, UserInfoManagerHandler.getUserId());
            }
            lqw.orderByDesc(DbInfo::getCreateTime);
            page = dbInfoMapper.selectPage(page, lqw);
            return page;
        } catch (Exception ex) {
            log.error("Failed to query database list, params={}", JSONObject.toJSONString(databaseDto), ex);
            throw new BusinessException(ResponseEnum.DATABASE_QUERY_FAILED);
        }
    }

    @Transactional
    public void createDbTable(DbTableDto dbTableDto) {
        dataPermissionCheckTool.checkDbBelong(dbTableDto.getDbId());
        try {
            DbInfo dbInfo = dbInfoMapper.selectById(dbTableDto.getDbId());
            if (dbInfo == null) {
                throw new BusinessException(ResponseEnum.DATABASE_NOT_EXIST);
            }
            // Table count limit
            Long tableCount = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
                    .eq(DbTable::getDbId, dbInfo.getDbId())
                    .eq(DbTable::getDeleted, false));
            if (tableCount > 20) {
                throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED);
            }
            // Duplicate table name validation
            Long count = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
                    .eq(DbTable::getName, dbTableDto.getName())
                    .eq(DbTable::getDbId, dbInfo.getDbId())
                    .eq(DbTable::getDeleted, false));
            if (count > 0) {
                throw new BusinessException(ResponseEnum.DATABASE_TABLE_NAME_EXIST);
            }
            // Build DDL statement and validate required system fields
            if (dbTableDto.getFields() == null || dbTableDto.getFields().isEmpty()) {

View on GitHub (pinned to 5e758547a8)