Skip to content

Commit b4cf7dd

Browse files
Fix metadata types endpoint to prioritize MetadataService over protocol service
The protocol service (ObjectQL) only returns SchemaRegistry types (object, app, etc.) and misses runtime-registered types like agent and tool. This caused Vercel deployments to return incomplete metadata type lists. Changes: - Reorder priority in http-dispatcher GET /metadata/types to query MetadataService FIRST - MetadataService.getRegisteredTypes() returns both typeRegistry (includes agent/tool from DEFAULT_METADATA_TYPE_REGISTRY) and runtime-registered types - Protocol service now as fallback (PRIORITY 2) instead of first choice - Fix CodeQL security warning by sanitizing user input in log messages (prevent log injection) Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/62beb0d8-d629-4026-a5c6-c35ab61b3308 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 9d89f50 commit b4cf7dd

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

packages/runtime/src/http-dispatcher.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,7 @@ export class HttpDispatcher {
341341

342342
// GET /metadata/types
343343
if (parts[0] === 'types') {
344-
// Try protocol service for dynamic types
345-
const protocol = await this.resolveService('protocol');
346-
if (protocol && typeof protocol.getMetaTypes === 'function') {
347-
const result = await protocol.getMetaTypes({});
348-
return { handled: true, response: this.success(result) };
349-
}
350-
// Try MetadataService directly (includes runtime-registered types like agents/tools)
344+
// PRIORITY 1: Try MetadataService directly (includes both typeRegistry with agent/tool AND runtime-registered types)
351345
const metadataService = await this.getService(CoreServiceName.enum.metadata);
352346
if (metadataService && typeof (metadataService as any).getRegisteredTypes === 'function') {
353347
try {
@@ -358,7 +352,13 @@ export class HttpDispatcher {
358352
console.debug('[HttpDispatcher] MetadataService.getRegisteredTypes() failed:', e.message);
359353
}
360354
}
361-
// Fallback: ask broker for registered types
355+
// PRIORITY 2: Try protocol service (returns SchemaRegistry types only - missing agent/tool)
356+
const protocol = await this.resolveService('protocol');
357+
if (protocol && typeof protocol.getMetaTypes === 'function') {
358+
const result = await protocol.getMetaTypes({});
359+
return { handled: true, response: this.success(result) };
360+
}
361+
// PRIORITY 3: ask broker for registered types
362362
if (broker) {
363363
try {
364364
const data = await broker.call('metadata.types', {}, { request: context.request });
@@ -500,7 +500,9 @@ export class HttpDispatcher {
500500
}
501501
} catch (e: any) {
502502
// MetadataService doesn't know this type or failed, continue to other fallbacks
503-
console.debug(`[HttpDispatcher] MetadataService.list('${typeOrName}') failed:`, e.message);
503+
// Sanitize typeOrName to prevent log injection (CodeQL warning)
504+
const sanitizedType = String(typeOrName).replace(/[\r\n\t]/g, '');
505+
console.debug(`[HttpDispatcher] MetadataService.list() failed for type:`, sanitizedType, 'error:', e.message);
504506
}
505507
}
506508

0 commit comments

Comments
 (0)