Skip to content

Commit 0c887c5

Browse files
committed
fix: add null check for messageService and improve ZodError type safety
1 parent 4929cce commit 0c887c5

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/environment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export async function validateTelegramConfig(
2929
return telegramEnvSchema.parse(config);
3030
} catch (error) {
3131
if (error instanceof z.ZodError) {
32-
const errorMessages = (error as any).errors
33-
.map((err: any) => `${err.path.join('.')}: ${err.message}`)
32+
const errorMessages = error.issues
33+
.map((err) => `${err.path.join('.')}: ${err.message}`)
3434
.join('\n');
3535
console.warn(`Telegram configuration validation failed:\n${errorMessages}`);
3636
}

src/messageManager.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,13 @@ export class MessageManager {
706706

707707
// Call the message handler directly instead of emitting events
708708
// This provides a clearer, more traceable flow for message processing
709-
await this.runtime.messageService!.handleMessage(this.runtime, memory, callback);
709+
if (!this.runtime.messageService) {
710+
logger.error('Message service is not available');
711+
throw new Error(
712+
'Message service is not initialized. Ensure the message service is properly configured.'
713+
);
714+
}
715+
await this.runtime.messageService.handleMessage(this.runtime, memory, callback);
710716
} catch (error) {
711717
logger.error(
712718
{

0 commit comments

Comments
 (0)