🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(search): cap marketplace page size at the Market API limit (#20618)
YuTengjing72f1bd2cf541
diff --git a/apps/server/src/routers/lambda/__tests__/search.test.ts b/apps/server/src/routers/lambda/__tests__/search.test.tsindex 86aaaefa070..fd0db678868 100644--- a/apps/server/src/routers/lambda/__tests__/search.test.ts+++ b/apps/server/src/routers/lambda/__tests__/search.test.ts@@ -156,6 +156,31 @@ describe('searchRouter', () => {expect(getUserSettings).not.toHaveBeenCalled();});+ it.each(['mcp', 'communityAgent'] as const)(+ 'caps the %s Market API page size at its maximum',+ async (type) => {+ getAssistantList.mockResolvedValue({ items: [] });+ const caller = searchRouter.createCaller({ userId: 'test-user' } as any);++ // The command menu requests 50 per type in its typed view.+ await caller.query({ limitPerType: 50, query: 'github', type });++ const listFn = type === 'mcp' ? getMcpList : getAssistantList;+ expect(listFn).toHaveBeenCalledWith(+ expect.objectContaining({ pageSize: 40 }),+ ...(type === 'communityAgent' ? [expect.anything()] : []),+ );+ },+ );++ it('keeps the requested limit for the locally paged legacy plugin catalog', async () => {+ const caller = searchRouter.createCaller({ userId: 'test-user' } as any);++ await caller.query({ limitPerType: 50, query: 'github', type: 'plugin' });++ expect(getPluginList).toHaveBeenCalledWith(expect.objectContaining({ pageSize: 50 }));+ });+it('returns a typed error when the community agent market search fails', async () => {const marketError = new Error('Market unavailable');getAssistantList.mockRejectedValue(marketError);diff --git a/apps/server/src/routers/lambda/search.ts b/apps/server/src/routers/lambda/search.tsindex 495323161ff..43feda6dd30 100644--- a/apps/server/src/routers/lambda/search.ts+++ b/apps/server/src/routers/lambda/search.ts@@ -11,6 +11,15 @@ import { getRestrictedKnowledgeBaseIds } from './_helpers/knowledgeBaseAccess';const MARKETPLACE_SEARCH_TYPES = new Set(['communityAgent', 'mcp', 'plugin']);+/**+ * The Market API rejects `pageSize` above 40 with `Invalid query parameters`.+ * The command menu's typed view asks for 50 per type, which made MCP searches+ * silently empty and community agent searches fail, so cap the MCP and community+ * agent calls. Plugin search pages the locally loaded legacy catalog and keeps the+ * requested limit.+ */+const MARKET_API_MAX_PAGE_SIZE = 40;+/*** Calculate relevance score for marketplace items* 1 = exact match, 2 = prefix match, 3 = contains match@@ -99,6 +108,7 @@ export const searchRouter = router({).query(async ({ input, ctx }) => {const { query, type, limitPerType = 5, locale } = input;+ const marketApiPageSize = Math.min(limitPerType, MARKET_API_MAX_PAGE_SIZE);// Early return for empty queryif (!query || query.trim() === '') return [];@@ -149,7 +159,7 @@ export const searchRouter = router({ctx.discoverService.getMcpList({locale,- pageSize: limitPerType,+ pageSize: marketApiPageSize,q: query,}).then((response) =>@@ -219,7 +229,7 @@ export const searchRouter = router({{includeAgentGroup: true,locale,- pageSize: limitPerType,+ pageSize: marketApiPageSize,q: query,},{ throwOnError: type === 'communityAgent' },