{"record":{"id":"07fd0e2510d83052","repo":"iflytek/astron-agent","slug":"database-query-failed","errorCode":"DATABASE_QUERY_FAILED","errorMessage":"DATABASE_QUERY_FAILED","messagePattern":"DATABASE_QUERY_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java","lineNumber":268,"sourceCode":"            Page<DbInfo> page = new Page<>(databaseDto.getPageNum(), databaseDto.getPageSize());\n            LambdaQueryWrapper<DbInfo> lqw = new QueryWrapper<DbInfo>().lambda()\n                    .eq(DbInfo::getDeleted, false)\n                    .and(StringUtils.isNotBlank(databaseDto.getSearch()),\n                            wrapper -> wrapper.like(DbInfo::getName, databaseDto.getSearch())\n                                    .or()\n                                    .like(DbInfo::getDescription, databaseDto.getSearch()));\n            if (spaceId != null) {\n                lqw.eq(DbInfo::getSpaceId, spaceId);\n            } else {\n                lqw.isNull(DbInfo::getSpaceId);\n                lqw.eq(DbInfo::getUid, UserInfoManagerHandler.getUserId());\n            }\n            lqw.orderByDesc(DbInfo::getCreateTime);\n            page = dbInfoMapper.selectPage(page, lqw);\n            return page;\n        } catch (Exception ex) {\n            log.error(\"Failed to query database list, params={}\", JSONObject.toJSONString(databaseDto), ex);\n            throw new BusinessException(ResponseEnum.DATABASE_QUERY_FAILED);\n        }\n    }\n\n    @Transactional\n    public void createDbTable(DbTableDto dbTableDto) {\n        dataPermissionCheckTool.checkDbBelong(dbTableDto.getDbId());\n        try {\n            DbInfo dbInfo = dbInfoMapper.selectById(dbTableDto.getDbId());\n            if (dbInfo == null) {\n                throw new BusinessException(ResponseEnum.DATABASE_NOT_EXIST);\n            }\n            // Table count limit\n            Long tableCount = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()\n                    .eq(DbTable::getDbId, dbInfo.getDbId())\n                    .eq(DbTable::getDeleted, false));\n            if (tableCount > 20) {\n                throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED);\n            }","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java#L250-L286","documentation":"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.","triggerScenarios":"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.","commonSituations":"Frontend sending unexpected query parameter types; DB outage or pool exhaustion; page index/size values out of supported range causing SQL errors.","solutions":["Inspect the 'Failed to query database list, params=' log entry for the root cause","Validate pagination and filter parameter types on the client before the request","Retry on transient connection errors","Check DB health and MyBatis-Plus mapper configuration"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"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; } }","preventionTips":["Validate pagination (page/size) and filter types client-side","Sanitize query parameters before mapping them to QueryWrapper conditions","Monitor DB connection pool and query latency"],"tags":["database","query","pagination","java"],"backgroundTag":"database-query-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}