Skip to content

fix: data layer — cache TTL NaN bug + synth error guard#205

Open
kingmylord wants to merge 1 commit intolangoustine69:mainfrom
kingmylord:feat/data-layer-fixes
Open

fix: data layer — cache TTL NaN bug + synth error guard#205
kingmylord wants to merge 1 commit intolangoustine69:mainfrom
kingmylord:feat/data-layer-fixes

Conversation

@kingmylord
Copy link

Closes #2

Bug fixes

cache.ts: TTL NaN when env var unset

Number(undefined) returns NaN, and NaN ?? 300 still returns NaN (nullish coalescing only catches null/undefined). In production with no CACHE_TTL_SECONDS set, cache entries never expired silently.

Fix: Use Number.isFinite() guard before applying the 300s default.

synth.ts: empty OpenAI response guard

Added explicit check for empty content in OpenAI response to fail fast with a clear error.

Tests added

  • cache.test.ts: verify default 300s TTL works with no args and no env var
  • cache.test.ts: verify CACHE_TTL_SECONDS env var is respected
  • synth.test.ts: single source scores lower than multiple sources

All 34 tests pass.

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.

[T2] Brave Search + LLM synthesis layer

1 participant