Skip to content

Commit b6bfec4

Browse files
committed
upd: updated validateCharacterConfig to give better feedback
1 parent 603be54 commit b6bfec4

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

packages/core/src/environment.ts

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z } from "zod";
22
import { ModelProviderName, Clients } from "./types";
3+
import elizaLogger from "./logger";
34

45
// TODO: TO COMPLETE
56
export const envSchema = z.object({
@@ -137,11 +138,26 @@ export function validateCharacterConfig(json: unknown): CharacterConfig {
137138
return CharacterSchema.parse(json);
138139
} catch (error) {
139140
if (error instanceof z.ZodError) {
140-
const errorMessages = error.errors
141-
.map((err) => `${err.path.join(".")}: ${err.message}`)
142-
.join("\n");
141+
const groupedErrors = error.errors.reduce(
142+
(acc, err) => {
143+
const path = err.path.join(".");
144+
if (!acc[path]) {
145+
acc[path] = [];
146+
}
147+
acc[path].push(err.message);
148+
return acc;
149+
},
150+
{} as Record<string, string[]>
151+
);
152+
153+
Object.entries(groupedErrors).forEach(([field, messages]) => {
154+
elizaLogger.error(
155+
`Validation errors in ${field}: ${messages.join(" - ")}`
156+
);
157+
});
158+
143159
throw new Error(
144-
`Character configuration validation failed:\n${errorMessages}`
160+
"Character configuration validation failed. Check logs for details."
145161
);
146162
}
147163
throw error;

0 commit comments

Comments
 (0)