fix: ensure AI provider config is saved correctly in admin

URGENT FIX: Admin form was not properly saving AI provider configuration,
causing 'AI_PROVIDER_TAGS is not configured' error even after setting OpenAI.

Changes:
- admin-settings-form.tsx: Added validation and error handling
- admin-settings.ts: Filter empty values before saving to DB
- setup-openai.ts: Script to initialize OpenAI as default provider

This fixes the critical bug where users couldn't use the app after
configuring OpenAI in the admin interface.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-12 23:16:26 +01:00
parent 8617117dec
commit 2393cacf35
4 changed files with 277 additions and 35 deletions

View File

@@ -39,16 +39,23 @@ export async function getSystemConfig() {
export async function updateSystemConfig(data: Record<string, string>) {
await checkAdmin()
try {
const operations = Object.entries(data).map(([key, value]) =>
// Filter out empty values but keep 'false' as valid
const filteredData = Object.fromEntries(
Object.entries(data).filter(([key, value]) => value !== '' && value !== null && value !== undefined)
)
console.log('Updating system config:', filteredData)
const operations = Object.entries(filteredData).map(([key, value]) =>
prisma.systemConfig.upsert({
where: { key },
update: { value },
create: { key, value }
})
)
await prisma.$transaction(operations)
revalidatePath('/admin/settings')
return { success: true }