fix: resolve engineering debt — lazy init, auth unification, RAG fix#2
Open
ymstar wants to merge 2 commits into
Open
fix: resolve engineering debt — lazy init, auth unification, RAG fix#2ymstar wants to merge 2 commits into
ymstar wants to merge 2 commits into
Conversation
1. auth.ts + user-sync.ts: merge into unified getDbUserId()
- Now fetches real Clerk user data (email, name) on account creation
- Removes user-sync.ts as redundant
- Updates sync-user route to use getDbUserId()
2. embeddings.ts: replace scattered Supabase client with lazy getter
- Module-level createClient() that read env vars at import time
replaced with createServerClient() via lazy getter
- Eliminates import-time crash when env vars are missing
3. embeddings.ts: fail loudly when OPENAI_API_KEY missing in production
- Hash-based fallback now throws in NODE_ENV=production
- Logs a warning in dev/test to make the fallback visible
4. rag.ts: fix truncation direction
- slice(-MAX) kept the tail (least relevant); now slice(0, MAX)
keeps the head (most relevant content from vector search)
The module-level createClient() with non-null assertions crashed at import time when NEXT_PUBLIC_SUPABASE_URL was missing. This blocked both dev server startup and production builds without env vars configured. - supabase export: changed from const to lazy getter function - createServerClient(): reads env vars at call time, throws with clear error messages when vars are missing - Nobody imports the supabase singleton directly; all callers use createServerClient()
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Verification