🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix: do not use cache for api keys if not enabled (#2748)
Max Deichmann0fa4b381fc41
diff --git a/web/jest.config.mjs b/web/jest.config.mjsindex 9c97d09ad1..6171c84c24 100644--- a/web/jest.config.mjs+++ b/web/jest.config.mjs@@ -39,4 +39,8 @@ const config = {],};+process.env = Object.assign(process.env, {+ LANGFUSE_CACHE_API_KEY_ENABLED: "true",+});+export default config;diff --git a/web/src/__tests__/api-auth.servertest.ts b/web/src/__tests__/api-auth.servertest.tsindex 106d204042..8cf25eecb3 100644--- a/web/src/__tests__/api-auth.servertest.ts+++ b/web/src/__tests__/api-auth.servertest.ts@@ -123,15 +123,17 @@ describe("Authenticate API calls", () => {maxRetriesPerRequest: null,});- afterEach(async () => {+ beforeEach(async () => {// if we do not remove the key, it will remain in the cache and// calling the test twice will not add the key to the cache+const keys = await redis.keys("api-key*");if (keys.length > 0) {await redis.del(keys);}});- beforeEach(async () => {++ afterEach(async () => {// if we do not remove the key, it will remain in the cache and// calling the test twice will not add the key to the cacheconst keys = await redis.keys("api-key*");diff --git a/web/src/features/public-api/server/apiAuth.ts b/web/src/features/public-api/server/apiAuth.tsindex 29e88898c1..890ae93072 100644--- a/web/src/features/public-api/server/apiAuth.ts+++ b/web/src/features/public-api/server/apiAuth.ts@@ -223,7 +223,7 @@ export class ApiAuthService {}async addApiKeyToRedis(hash: string, apiKey: ApiKey) {- if (!this.redis || !env.LANGFUSE_CACHE_API_KEY_ENABLED) {+ if (!this.redis || env.LANGFUSE_CACHE_API_KEY_ENABLED !== "true") {return;}@@ -240,7 +240,7 @@ export class ApiAuthService {}async fetchApiKeyFromRedis(hash: string) {- if (!this.redis || !env.LANGFUSE_CACHE_API_KEY_ENABLED) {+ if (!this.redis || env.LANGFUSE_CACHE_API_KEY_ENABLED !== "true") {return null;}