fix(agents): convert null values to undefined in database responses

Ensure type consistency by converting null values from database to undefined as specified in type definitions
This commit is contained in:
icarus 2025-09-19 13:14:20 +08:00
parent ae9c78e643
commit eb3ff6f570
2 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import { type Client, createClient } from '@libsql/client'
import { loggerService } from '@logger'
import { objectKeys } from '@types'
import { drizzle, type LibSQLDatabase } from 'drizzle-orm/libsql'
import fs from 'fs'
import path from 'path'
@ -150,6 +151,13 @@ export abstract class BaseService {
}
}
// convert null from db to undefined to satisfy type definition
for (const key of objectKeys(data)) {
if (deserialized[key] === null) {
deserialized[key] = undefined
}
}
return deserialized
}

View File

@ -1,6 +1,8 @@
/**
* Database entity types for Agent, Session, and SessionMessage
* Shared between main and renderer processes
*
* WARNING: Any null value will be converted to undefined from api.
*/
import { ModelMessage, modelMessageSchema, TextStreamPart } from 'ai'
import { z } from 'zod'