-
Notifications
You must be signed in to change notification settings - Fork 13
fix: keep LLM credentials out of the eval scorer environment #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -475,20 +475,57 @@ async function smokeFrontendBuildTooling() { | |
| cpSync(join(ROOT, FRONTEND_EVAL, 'tests'), join(workspace, 'tests'), { | ||
| recursive: true, | ||
| }); | ||
| writeFileSync(join(workspace, 'src', 'App.tsx'), GOOD_FRONTEND_APP); | ||
| writeFileSync( | ||
| join(workspace, '.env.local'), | ||
| join(workspace, 'vite.config.ts'), | ||
| [ | ||
| 'VITE_SUPABASE_URL=http://supabase-evals.local', | ||
| 'VITE_SUPABASE_ANON_KEY=supabase-evals-anon-key', | ||
| "import { defineConfig } from 'vite';", | ||
| "import react from '@vitejs/plugin-react';", | ||
| '', | ||
| 'if (', | ||
| ' process.env.ANTHROPIC_API_KEY ||', | ||
| ' process.env.OPENAI_API_KEY ||', | ||
| ' process.env.AI_GATEWAY_API_KEY', | ||
| ") throw new Error('inherited LLM credential');", | ||
| '', | ||
| 'export default defineConfig({ plugins: [react()] });', | ||
| '', | ||
| ].join('\n') | ||
| ); | ||
| writeFileSync(join(workspace, 'src', 'App.tsx'), GOOD_FRONTEND_APP); | ||
| writeFileSync( | ||
| join(workspace, 'tests', 'environment.test.ts'), | ||
| [ | ||
| "import { expect, test } from 'vitest';", | ||
| '', | ||
| "test('does not inherit LLM credentials', () => {", | ||
| ' expect(process.env.ANTHROPIC_API_KEY).toBeUndefined();', | ||
| ' expect(process.env.OPENAI_API_KEY).toBeUndefined();', | ||
| ' expect(process.env.AI_GATEWAY_API_KEY).toBeUndefined();', | ||
|
Comment on lines
+501
to
+503
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These three names are the only thing the fixture samples, so a revert that spreads Non-blocking: |
||
| '});', | ||
| '', | ||
| ].join('\n') | ||
| ); | ||
|
|
||
| const originalEnv = { | ||
| ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY, | ||
| OPENAI_API_KEY: process.env.OPENAI_API_KEY, | ||
| AI_GATEWAY_API_KEY: process.env.AI_GATEWAY_API_KEY, | ||
| }; | ||
| process.env.ANTHROPIC_API_KEY = 'test-anthropic-key'; | ||
| process.env.OPENAI_API_KEY = 'test-openai-key'; | ||
| process.env.AI_GATEWAY_API_KEY = 'test-ai-gateway-key'; | ||
|
|
||
| const build = await viteBuild(workspace); | ||
| assert.equal(build.ok, true, build.stderr || build.stdout); | ||
| const vitest = await vitestRun(workspace); | ||
| assert.equal(vitest.ok, true, vitest.stderr || vitest.stdout); | ||
| try { | ||
| const build = await viteBuild(workspace); | ||
| assert.equal(build.ok, true, build.stderr || build.stdout); | ||
| const vitest = await vitestRun(workspace); | ||
| assert.equal(vitest.ok, true, vitest.stderr || vitest.stdout); | ||
| } finally { | ||
| for (const [name, value] of Object.entries(originalEnv)) { | ||
| if (value === undefined) delete process.env[name]; | ||
| else process.env[name] = value; | ||
| } | ||
| } | ||
|
|
||
| console.log('PASS frontend vite/react/supalite build + test tooling'); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flipped the fourth parameter's meaning from "extras merged over
process.env" to "the child's whole environment", while keeping the nameenvand the= {}default. The invariant now lives at both call sites, so a futurerunNodeBin(bin, args, cwd)gets a bare env with no signal anything's wrong.Non-blocking, but building it here deletes
PROJECT_ENVand two of the four hunks in this file:viteBuildthen goes back to its three-argument call, andvitestRunto{ SUPABASE_EVALS_WORKSPACE: workspace }.