Skip to content

Commit 4ce578a

Browse files
committed
fix: BYOK config lookup used nonexistent tenant_id column in OR filter
The companies table has no tenant_id column. The or=(id.eq.X,tenant_id.eq.X) PostgREST filter was returning 400 or empty results, causing BYOK to always fall back to the default Cloudflare model. Simplified to: id=eq. which is the correct PK lookup.
1 parent e863daf commit 4ce578a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

backend/simpatico-ats.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,16 @@ async function getCompanyAIConfig(env, tenantId) {
523523
}
524524

525525
try {
526-
const url = `${env.SUPABASE_URL}/rest/v1/companies?select=ai_provider,ai_api_key,ai_base_url,ai_model&or=(id.eq.${tenantId},tenant_id.eq.${tenantId})&limit=1`;
526+
const url = `${env.SUPABASE_URL}/rest/v1/companies?select=ai_provider,ai_api_key,ai_base_url,ai_model&id=eq.${tenantId}&limit=1`;
527527
const res = await fetch(url, {
528528
headers: {
529529
apikey: env.SUPABASE_SERVICE_KEY,
530530
Authorization: `Bearer ${env.SUPABASE_SERVICE_KEY}`,
531531
},
532532
});
533533
if (!res.ok) {
534-
console.warn("[BYOK] Failed to fetch company AI config:", res.status);
534+
const errBody = await res.text().catch(() => "");
535+
console.warn(`[BYOK] Failed to fetch company AI config: status=${res.status}, body=${errBody}`);
535536
return null;
536537
}
537538
const rows = await res.json();

0 commit comments

Comments
 (0)