Handling double stringify JSON parsing

This commit is contained in:
sjiampojamarn
2025-10-05 10:35:35 -07:00
parent f141d4719c
commit 02adafbd4b

View File

@@ -67,8 +67,10 @@ fs.readdirSync(migrationsFolder)
`);
messages.forEach((msg: any) => {
if (msg.type === 'user') {
while (typeof msg.metadata === 'string') {
msg.metadata = JSON.parse(msg.metadata || '{}');
}
if (msg.type === 'user') {
insertMessage.run(
'user',
msg.chatId,
@@ -78,7 +80,6 @@ fs.readdirSync(migrationsFolder)
'[]',
);
} else if (msg.type === 'assistant') {
msg.metadata = JSON.parse(msg.metadata || '{}');
insertMessage.run(
'assistant',
msg.chatId,