Skip to content

Commit efcd6a4

Browse files
committed
fix: unify env var configuration -- API_KEY/DEV_API_KEY mismatch, missing vars, stale references
Problems fixed: 1. API_KEY vs DEV_API_KEY: .env.example had API_KEY but backend reads DEV_API_KEY. docker-compose passed API_KEY which backend ignored. Now .env.example documents DEV_API_KEY with clear dev-only warning. 2. EMBEDDING_MODEL mismatch: .env.example said text-embedding-3-large but code defaults to text-embedding-3-small. Aligned to match code. 3. Missing vars: added DEV_API_KEY, DEBUG, LOG_LEVEL, REDIS_URL to .env.example. Self-hosters can now see every configurable option. 4. Dead env vars: removed SUPABASE_KEY and API_KEY from conftest (nobody reads them). 5. docker-compose: passes DEV_API_KEY + DEBUG + EMBEDDING_MODEL now. 6. startup_checks: added GITHUB_CLIENT_ID/SECRET and DISCORD_FEEDBACK_WEBHOOK to optional vars. 284 tests pass. Closes OPE-72
1 parent a69f505 commit efcd6a4

4 files changed

Lines changed: 22 additions & 20 deletions

File tree

.env.example

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
OPENAI_API_KEY=sk-...
77

88
# Embedding Model (Optional)
9-
# Options: text-embedding-3-small (faster, cheaper), text-embedding-3-large (better quality)
10-
# Default: text-embedding-3-large
11-
EMBEDDING_MODEL=text-embedding-3-large
9+
# Options: text-embedding-3-small (default, faster/cheaper), text-embedding-3-large (better quality)
10+
EMBEDDING_MODEL=text-embedding-3-small
1211

13-
# Pinecone API (Required)
12+
# Pinecone API (Required)
1413
# Get from: https://app.pinecone.io/
1514
PINECONE_API_KEY=pcsk_...
1615
PINECONE_INDEX_NAME=codeintel
@@ -19,13 +18,16 @@ PINECONE_INDEX_NAME=codeintel
1918
# Get from: https://app.supabase.com/project/_/settings/api
2019
SUPABASE_URL=https://your-project.supabase.co
2120
SUPABASE_ANON_KEY=eyJ...
22-
# From Project Settings -> API -> JWT Secret
2321
SUPABASE_JWT_SECRET=your-jwt-secret
24-
# From Project Settings -> API -> service_role key
2522
SUPABASE_SERVICE_ROLE_KEY=eyJ...
2623

27-
# Backend API
28-
API_KEY=change-this-secret-key-for-production
24+
# Development API Key (Optional -- dev/test only, ignored in production)
25+
# Used to bypass JWT auth when DEBUG=true. Never set in production.
26+
DEV_API_KEY=
27+
DEBUG=false
28+
LOG_LEVEL=INFO
29+
30+
# Backend API URL (used by MCP server and frontend)
2931
BACKEND_API_URL=http://backend:8000
3032
FRONTEND_URL=http://localhost:3000
3133

@@ -37,31 +39,28 @@ GITHUB_REDIRECT_URI=http://localhost:3000/auth/github/callback
3739

3840
# CORS Configuration (Security)
3941
# Comma-separated list of allowed origins
40-
# Development: http://localhost:3000
41-
# Production: https://your-app.vercel.app,https://your-domain.com
4242
ALLOWED_ORIGINS=http://localhost:3000
4343

4444
# Redis (auto-configured in Docker, set REDIS_URL in Railway)
4545
REDIS_HOST=redis
4646
REDIS_PORT=6379
47+
REDIS_URL=
4748

4849
# Sentry Error Tracking (Optional but recommended for production)
4950
# Get DSN from: https://sentry.io -> Settings -> Projects -> Client Keys
5051
SENTRY_DSN=
5152
SENTRY_SEND_PII=false
5253
SENTRY_INCLUDE_LOCAL_VARS=false
53-
ENVIRONMENT=development # development, staging, production
54+
ENVIRONMENT=development
5455

55-
# Discord Webhook (Optional - for feedback notifications)
56+
# Discord Webhook (Optional -- for feedback notifications)
5657
DISCORD_FEEDBACK_WEBHOOK=
5758

58-
# Search V2 Configuration
59-
# Cohere API for reranking (Optional - improves search quality)
59+
# Cohere API for reranking (Optional -- improves search quality)
6060
# Get from: https://dashboard.cohere.com/api-keys
61-
# Free tier: 10K requests/month
6261
COHERE_API_KEY=
6362
SEARCH_V2_ENABLED=true
6463

65-
# Voyage AI - code-specific embeddings (Optional - improves code search quality)
64+
# Voyage AI (Optional -- code-specific embeddings for better search)
6665
# Get from: https://dash.voyageai.com/
6766
VOYAGE_API_KEY=

backend/config/startup_checks.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
("SENTRY_SEND_PII", "Send user emails to Sentry", "PII disabled (privacy safe)"),
2727
("SENTRY_INCLUDE_LOCAL_VARS", "Include local vars in Sentry traces", "Local vars excluded"),
2828
("REDIS_HOST", "Redis host for caching", "Using default localhost"),
29+
("GITHUB_CLIENT_ID", "GitHub OAuth client ID", "GitHub repo import disabled"),
30+
("GITHUB_CLIENT_SECRET", "GitHub OAuth client secret", "GitHub repo import disabled"),
31+
("DISCORD_FEEDBACK_WEBHOOK", "Discord webhook for feedback", "Feedback notifications disabled"),
2932
]
3033

3134

backend/tests/conftest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
# Set test environment BEFORE imports
1212
os.environ["DEBUG"] = "true"
13-
os.environ["DEV_API_KEY"] = "test-secret-key" # New env var for dev key
14-
os.environ["API_KEY"] = "test-secret-key" # Legacy support
13+
os.environ["DEV_API_KEY"] = "test-secret-key"
1514
os.environ["OPENAI_API_KEY"] = "sk-test-key"
1615
os.environ["PINECONE_API_KEY"] = "pcsk-test"
1716
os.environ["PINECONE_INDEX_NAME"] = "test-index"
1817
os.environ["SUPABASE_URL"] = "https://test.supabase.co"
19-
os.environ["SUPABASE_KEY"] = "test-key"
2018
os.environ["SUPABASE_ANON_KEY"] = "test-anon-key"
2119
os.environ["SUPABASE_JWT_SECRET"] = "test-jwt-secret"
2220

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ services:
3535
- SUPABASE_ANON_KEY=${SUPABASE_ANON_KEY}
3636
- SUPABASE_JWT_SECRET=${SUPABASE_JWT_SECRET}
3737
- SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}
38-
- API_KEY=${API_KEY}
38+
- DEV_API_KEY=${DEV_API_KEY}
39+
- DEBUG=${DEBUG:-false}
40+
- EMBEDDING_MODEL=${EMBEDDING_MODEL:-text-embedding-3-small}
3941
- BACKEND_API_URL=http://backend:8000
4042
- DISCORD_FEEDBACK_WEBHOOK=${DISCORD_FEEDBACK_WEBHOOK}
4143
- COHERE_API_KEY=${COHERE_API_KEY}

0 commit comments

Comments
 (0)