iflytek/astron-agent · error · BusinessException

DATABASE_QUERY_FAILED

DATABASE_QUERY_FAILED

Error message

DATABASE_QUERY_FAILED

What it means

Catch-all in DatabaseService.selectPage: any exception while building the query wrapper or executing dbInfoMapper.selectPage is converted to DATABASE_QUERY_FAILED. This is a read-path failure, so no data is modified; the cause (bad filter params, SQL error, connection issue) is only visible in the log.

Solutions

  1. Inspect the 'Failed to query database list, params=' log entry for the root cause
  2. Validate pagination and filter parameter types on the client before the request
  3. Retry on transient connection errors
  4. Check DB health and MyBatis-Plus mapper configuration
Defensive patterns

Strategy: retry

Try / catch

try { page = databaseService.selectPage(dto); } catch (BusinessException e) { if ("DATABASE_QUERY_FAILED".equals(e.getCode())) { /* retry once; else check filters/DB health */ } else { throw e; } }

Prevention

When it happens

Trigger: Paged listing with malformed filter fields (wrong type in name/description filter); DB connection failure; SQL error from unexpected query parameters; invalid pagination parameters causing MyBatis-Plus errors.

Common situations: Frontend sending unexpected query parameter types; DB outage or pool exhaustion; page index/size values out of supported range causing SQL errors.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

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

            Page<DbInfo> page = new Page<>(databaseDto.getPageNum(), databaseDto.getPageSize());
            LambdaQueryWrapper<DbInfo> lqw = new QueryWrapper<DbInfo>().lambda()
                    .eq(DbInfo::getDeleted, false)
                    .and(StringUtils.isNotBlank(databaseDto.getSearch()),
                            wrapper -> wrapper.like(DbInfo::getName, databaseDto.getSearch())
                                    .or()
                                    .like(DbInfo::getDescription, databaseDto.getSearch()));
            if (spaceId != null) {
                lqw.eq(DbInfo::getSpaceId, spaceId);
            } else {
                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);
            }

View on GitHub (pinned to 5e758547a8)