Skip to content

Commit 916d4c0

Browse files
Claudehotlong
andauthored
Add debug logging to diagnose metadata service availability
Added comprehensive logging to understand why MetadataService might not be available or returning incomplete types in production: - Log whether MetadataService is retrieved successfully - Log whether getRegisteredTypes method exists - Log the returned types from each fallback attempt - Log warnings when falling back to protocol service or hardcoded defaults This will help identify if: 1. MetadataService is not being registered properly 2. getRegisteredTypes method is missing 3. The method is throwing errors 4. We're hitting unexpected fallback paths Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/b2f61841-8fb0-4cd5-91c0-b85aef875a82 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent b4cf7dd commit 916d4c0

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

packages/runtime/src/http-dispatcher.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,31 +343,39 @@ export class HttpDispatcher {
343343
if (parts[0] === 'types') {
344344
// PRIORITY 1: Try MetadataService directly (includes both typeRegistry with agent/tool AND runtime-registered types)
345345
const metadataService = await this.getService(CoreServiceName.enum.metadata);
346+
console.log('[HttpDispatcher] MetadataService retrieved:', !!metadataService, 'has getRegisteredTypes:', typeof (metadataService as any)?.getRegisteredTypes);
346347
if (metadataService && typeof (metadataService as any).getRegisteredTypes === 'function') {
347348
try {
348349
const types = await (metadataService as any).getRegisteredTypes();
350+
console.log('[HttpDispatcher] MetadataService.getRegisteredTypes() returned:', types);
349351
return { handled: true, response: this.success({ types }) };
350352
} catch (e: any) {
351353
// Log error but continue to fallbacks
352-
console.debug('[HttpDispatcher] MetadataService.getRegisteredTypes() failed:', e.message);
354+
console.warn('[HttpDispatcher] MetadataService.getRegisteredTypes() failed:', e.message, e.stack);
353355
}
356+
} else {
357+
console.log('[HttpDispatcher] MetadataService not available or missing getRegisteredTypes, falling back to protocol service');
354358
}
355359
// PRIORITY 2: Try protocol service (returns SchemaRegistry types only - missing agent/tool)
356360
const protocol = await this.resolveService('protocol');
357361
if (protocol && typeof protocol.getMetaTypes === 'function') {
358362
const result = await protocol.getMetaTypes({});
363+
console.log('[HttpDispatcher] Protocol service returned types:', result);
359364
return { handled: true, response: this.success(result) };
360365
}
361366
// PRIORITY 3: ask broker for registered types
362367
if (broker) {
363368
try {
364369
const data = await broker.call('metadata.types', {}, { request: context.request });
370+
console.log('[HttpDispatcher] Broker returned types:', data);
365371
return { handled: true, response: this.success(data) };
366-
} catch {
372+
} catch (e) {
373+
console.log('[HttpDispatcher] Broker call failed:', e);
367374
// fall through to hardcoded defaults
368375
}
369376
}
370377
// Last resort: hardcoded defaults
378+
console.warn('[HttpDispatcher] Falling back to hardcoded defaults for metadata types');
371379
return { handled: true, response: this.success({ types: ['object', 'app', 'plugin'] }) };
372380
}
373381

0 commit comments

Comments
 (0)