lobehub/lobehub · error · Error
Failed to get agent group list: ${response.statusText}
Error message
Failed to get agent group list: ${response.statusText} What it means
Inner throw in `getAgentGroupList` (agentGroup.ts:578) when the GET to `${MARKET_BASE_URL}/api/v1/agent-group/list` returns non-2xx. The message embeds the upstream `statusText`, which is what the client ultimately sees after the outer catch preserves `error.message`. This is a read operation scoped by pagination query params (`page`, `pageSize`).
Source
Thrown at apps/server/src/routers/lambda/market/agentGroup.ts:578
if (!headers['x-lobe-trust-token'] && accessToken) {
headers['Authorization'] = `Bearer ${accessToken}`;
}
const response = await fetch(listUrl, {
headers,
method: 'GET',
});
if (!response.ok) {
const errorText = await response.text();
log(
'Get agent group list failed: %s %s - %s',
response.status,
response.statusText,
errorText,
);
throw new Error(`Failed to get agent group list: ${response.statusText}`);
}
const result = await response.json();
log('Get agent group list success: count=%d', result.totalCount);
// Transform items to match getGroupAgentList format from DiscoverService
const transformedItems = (result.items || []).map((group: any) => ({
author: group.author || '',
avatar: group.avatar || '👥',
category: group.category,
createdAt: group.createdAt,
description: group.description || '',
homepage: discoverUrl('group_agent', group.identifier),
identifier: group.identifier,
installCount: group.installCount || 0,
isFeatured: group.isFeatured || false,
isOfficial: group.isOfficial || false,
isValidated: group.isValidated,View on GitHub (pinned to 10f24d7ade)
Solutions
- Read the `statusText` embedded in the message to classify: 'Unauthorized' → auth, 'Bad Request' → query params, 'Internal Server Error' → upstream.
- Validate pagination inputs on the client (`page >= 1`, `pageSize` within Market's allowed range) before calling the procedure.
- Confirm auth: `DEBUG=lambda-router:market:agent-group` shows whether `x-lobe-trust-token` or `Authorization` was attached.
- curl `MARKET_BASE_URL/api/v1/agent-group/list?page=1&pageSize=20` with the bearer token to isolate client vs upstream.
Example fix
// before
throw new Error(`Failed to get agent group list: ${response.statusText}`);
// after — include the parsed upstream body so 'Bad Request' reasons are visible
throw new Error(`Failed to get agent group list (${response.status}): ${errorText || response.statusText}`); Defensive patterns
Strategy: validation
Validate before calling
// Validate pagination before calling the list endpoint
if (!Number.isInteger(page) || page < 1) throw new Error('page must be >= 1');
if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100) throw new Error('pageSize out of range'); Type guard
function isAgentGroupList(v: unknown): v is { items: unknown[]; totalCount: number; currentPage: number; pageSize: number; totalPages: number } {
const r = v as Record<string, unknown>;
return !!r && Array.isArray(r.items) && typeof r.totalCount === 'number';
} Try / catch
try {
const list = await trpc.market.agentGroup.getAgentGroupList.query({ page, pageSize });
} catch (e) {
const msg = (e as Error)?.message ?? '';
if (/unauthorized|forbidden/i.test(msg)) { /* re-auth */ }
else if (/bad request/i.test(msg)) { /* fix pagination */ }
else throw e;
} Prevention
- Clamp page/pageSize to Market's accepted range on the client.
- Ensure auth context is populated before the first list fetch.
- Confirm MARKET_BASE_URL and the /agent-group/list route version.
When it happens
Trigger: Market list endpoint returns 401/403 (no/invalid auth token), 400 (invalid `page`/`pageSize`/`category` query), 5xx (Market outage); Market under heavy load timing out.
Common situations: Discover page loads before auth middleware has populated `marketOidcAccessToken`; pagination state corrupted on the client so `page` is 0 or negative and Market rejects it; Market deploy missing the `/agent-group/list` route version expected by this client.
Related errors
- Failed to get agent group forks: ${response.statusText}
- Failed to publish agent group: ${response.statusText}
- Failed to unpublish agent group: ${response.statusText}
- INTERNAL_SERVER_ERROR
- INTERNAL_SERVER_ERROR
AI-assisted analysis of lobehub/lobehub@10f24d7ade (2026-08-12).
Data as JSON: /api/errors/c3f6d748334a99aa.
Report an issue: GitHub.