Skip to content

Fix missing OpenAI embeddings key handling - #1007

Open
yjm7vj wants to merge 1 commit into
mainfrom
fix/1004-inference-search-error
Open

Fix missing OpenAI embeddings key handling#1007
yjm7vj wants to merge 1 commit into
mainfrom
fix/1004-inference-search-error

Conversation

@yjm7vj

@yjm7vj yjm7vj commented Jul 7, 2026

Copy link
Copy Markdown

Description

Fixes #1004

Removes the NOTAKEY fallback for OPENAI_EMBEDDINGS_KEY in the OpenAI embeddings client setup.

Previously, when OPENAI_EMBEDDINGS_KEY was missing, the app initialized the OpenAI client with the placeholder value NOTAKEY, causing inference search to fail later with a generic OpenAI/auth error. This change fails early with a clear missing environment variable error, making the root cause easier to diagnose in logs.

Checklist

  • You've included unit or integration tests for your change, where applicable.
    • Not applicable; this is an environment variable guard/config handling change.
  • You've included inline docs for your change, where applicable.
    • Not applicable; the thrown error message documents the required env var.
  • Any components that you've modified are accessible.
    • Not applicable; no UI components were modified.
  • You've used conventional commits where appropriate

@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
internal-dashboard Ready Ready Preview, Comment Jul 7, 2026 7:33pm
nightcrawler Ready Ready Preview, Comment Jul 7, 2026 7:33pm

@rcjasub rcjasub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes — the fix moves the missing-key check to module load time instead of scoping it to where the key is actually used, which introduces a regression.

packages/db/src/utils/get-embedding.ts now throws as soon as the module is imported, not when getEmbedding() is called. queries.ts statically imports getEmbedding, and its getDefaultDropdownItems() (lines 38–77) never calls it — it only queries IMPs/seed products directly. So the nav-bar's default (empty-query) search dropdown now hard-crashes whenever OPENAI_EMBEDDINGS_KEY is missing, even though that path never touched embeddings before. It also bypasses the graceful-degradation try/catch already in queries.ts/search.ts, since those only wrap runtime calls, not module evaluation.

Suggestion: move the check inside getEmbedding() (or lazily construct the client on first call), consistent with how connection.ts handles DATABASE_URL — checked lazily, at use time, not at import.

Otherwise the fix is correct and the error message is clear for #1004 — just needs to be scoped narrower before merging. Let me know how that goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inference search shows "Something went wrong loading results. Please try again."

2 participants