Files
ai-kit/test
CatoandClaude Opus 5 e7b80bc78c fix: read the probe secret per request — a captured one cannot be rotated, or tested (#41)
Found immediately, wiring the probe into the second app.

A handler is built once and reused, because its cache has to live
somewhere. So a plain `secret` string is whatever the environment held on
the FIRST request that reached it. Two consequences, one operational and
one that blocks the work:

  - rotating AI_PROBE_SECRET needs a process restart, which is not what
    anyone expects of an env var read at request time;
  - the route is untestable. The first test that runs before a secret is
    configured pins every later one to 501, because the handler it built
    captured `undefined`. That is exactly what happened: six of eight new
    tests in the consuming app failed on "expected 501".

`secret` now also accepts a function, read per request. A plain string
still works and still behaves as before.

Verified by mutation: capturing instead of calling turns exactly the test
that names it red.


Claude-Session: https://claude.ai/code/session_01NHDLTKGirKU7He8q2YR2y4

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 06:55:55 -07:00
..